]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
filestore: fix crash if keyword setup fails
authorVictor Julien <victor@inliniac.net>
Fri, 31 Oct 2014 12:41:39 +0000 (13:41 +0100)
committerVictor Julien <victor@inliniac.net>
Fri, 31 Oct 2014 12:41:39 +0000 (13:41 +0100)
SigMatch would be added to list, then the alproto check failed, leading
to freeing of sm. But as it was still in the list, the list now contained
a dangling pointer.

src/detect-filestore.c

index e88c95eeb6887eaeb7df4d37a3b114b7a2405026..f16fc4aa1edd5a080077a80216ff03df257ba197 100644 (file)
@@ -411,9 +411,6 @@ static int DetectFilestoreSetup (DetectEngineCtx *de_ctx, Signature *s, char *st
         sm->ctx = NULL;
     }
 
-    SigMatchAppendSMToList(s, sm, DETECT_SM_LIST_FILEMATCH);
-    s->filestore_sm = sm;
-
     if (s->alproto != ALPROTO_HTTP && s->alproto != ALPROTO_SMTP) {
         SCLogError(SC_ERR_CONFLICTING_RULE_KEYWORDS, "rule contains conflicting keywords.");
         goto error;
@@ -423,6 +420,9 @@ static int DetectFilestoreSetup (DetectEngineCtx *de_ctx, Signature *s, char *st
         AppLayerHtpNeedFileInspection();
     }
 
+    SigMatchAppendSMToList(s, sm, DETECT_SM_LIST_FILEMATCH);
+    s->filestore_sm = sm;
+
     s->flags |= SIG_FLAG_FILESTORE;
     return 0;