From: Justin Viiret Date: Mon, 23 May 2016 04:06:00 +0000 (+1000) Subject: mpm-hs,spm-hs: don't call hs_scan() for zero bytes X-Git-Tag: suricata-3.1RC1~81 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a765cfde191aaa37b797d8579d523a45a9fe5895;p=thirdparty%2Fsuricata.git mpm-hs,spm-hs: don't call hs_scan() for zero bytes --- diff --git a/src/util-mpm-hs.c b/src/util-mpm-hs.c index 8b993ae160..ae0de5e0a9 100644 --- a/src/util-mpm-hs.c +++ b/src/util-mpm-hs.c @@ -919,6 +919,10 @@ uint32_t SCHSSearch(const MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, SCHSThreadCtx *hs_thread_ctx = (SCHSThreadCtx *)(mpm_thread_ctx->ctx); const PatternDatabase *pd = ctx->pattern_db; + if (unlikely(buflen == 0)) { + return 0; + } + SCHSCallbackCtx cctx = {.ctx = ctx, .pmq = pmq, .match_count = 0}; /* scratch should have been cloned from g_scratch_proto at thread init. */ diff --git a/src/util-spm-hs.c b/src/util-spm-hs.c index 5ca0d333d0..898b6e9067 100644 --- a/src/util-spm-hs.c +++ b/src/util-spm-hs.c @@ -141,6 +141,10 @@ static uint8_t *HSScan(const SpmCtx *ctx, SpmThreadCtx *thread_ctx, const SpmHsCtx *sctx = ctx->ctx; hs_scratch_t *scratch = thread_ctx->ctx; + if (unlikely(haystack_len == 0)) { + return NULL; + } + uint64_t match_offset = UINT64_MAX; hs_error_t err = hs_scan(sctx->db, (const char *)haystack, haystack_len, 0, scratch, MatchEvent, &match_offset);