From: Victor Julien Date: Fri, 31 Oct 2014 12:41:39 +0000 (+0100) Subject: filestore: fix crash if keyword setup fails X-Git-Tag: suricata-2.1beta2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f7c2c219cd4b268a4bbb105dbd14e1d0b36b8ea0;p=thirdparty%2Fsuricata.git filestore: fix crash if keyword setup fails 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. --- diff --git a/src/detect-filestore.c b/src/detect-filestore.c index e88c95eeb6..f16fc4aa1e 100644 --- a/src/detect-filestore.c +++ b/src/detect-filestore.c @@ -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;