From f7c2c219cd4b268a4bbb105dbd14e1d0b36b8ea0 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Fri, 31 Oct 2014 13:41:39 +0100 Subject: [PATCH] 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. --- src/detect-filestore.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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;