From: Justin Viiret Date: Mon, 23 May 2016 01:06:39 +0000 (+1000) Subject: app-layer-smtp: init mpm thread ctx after prepare X-Git-Tag: suricata-3.1RC1~79 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=68ddcdccde5d4d6435d405d6ebaa64041fe54583;p=thirdparty%2Fsuricata.git app-layer-smtp: init mpm thread ctx after prepare This allows the Hyperscan MPM to correctly allocate scratch. --- diff --git a/src/app-layer-smtp.c b/src/app-layer-smtp.c index 8bdb1f54ff..98870a8e24 100644 --- a/src/app-layer-smtp.c +++ b/src/app-layer-smtp.c @@ -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,