]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
app-layer-smtp: init mpm thread ctx after prepare
authorJustin Viiret <justin.viiret@intel.com>
Mon, 23 May 2016 01:06:39 +0000 (11:06 +1000)
committerVictor Julien <victor@inliniac.net>
Fri, 27 May 2016 13:13:54 +0000 (15:13 +0200)
This allows the Hyperscan MPM to correctly allocate scratch.

src/app-layer-smtp.c

index 8bdb1f54ff44edb37402f52673d73267fb76af26..98870a8e244729b28b9690d7cd0981a933dda15a 100644 (file)
@@ -1437,13 +1437,6 @@ static void SMTPSetMpmState(void)
     memset(smtp_mpm_ctx, 0, sizeof(MpmCtx));
     MpmInitCtx(smtp_mpm_ctx, SMTP_MPM);
 
-    smtp_mpm_thread_ctx = SCMalloc(sizeof(MpmThreadCtx));
-    if (unlikely(smtp_mpm_thread_ctx == NULL)) {
-        exit(EXIT_FAILURE);
-    }
-    memset(smtp_mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
-    MpmInitThreadCtx(smtp_mpm_thread_ctx, SMTP_MPM);
-
     uint32_t i = 0;
     for (i = 0; i < sizeof(smtp_reply_map)/sizeof(SCEnumCharMap) - 1; i++) {
         SCEnumCharMap *map = &smtp_reply_map[i];
@@ -1454,6 +1447,13 @@ static void SMTPSetMpmState(void)
     }
 
     mpm_table[SMTP_MPM].Prepare(smtp_mpm_ctx);
+
+    smtp_mpm_thread_ctx = SCMalloc(sizeof(MpmThreadCtx));
+    if (unlikely(smtp_mpm_thread_ctx == NULL)) {
+        exit(EXIT_FAILURE);
+    }
+    memset(smtp_mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
+    MpmInitThreadCtx(smtp_mpm_thread_ctx, SMTP_MPM);
 }
 
 int SMTPStateGetEventInfo(const char *event_name,