]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
mpm-hs,spm-hs: don't call hs_scan() for zero bytes
authorJustin Viiret <justin.viiret@intel.com>
Mon, 23 May 2016 04:06:00 +0000 (14:06 +1000)
committerVictor Julien <victor@inliniac.net>
Fri, 27 May 2016 13:13:54 +0000 (15:13 +0200)
src/util-mpm-hs.c
src/util-spm-hs.c

index 8b993ae1608966111ddf27a834383b547d981a7e..ae0de5e0a9f06e45efa645cc742db44bbd72df3a 100644 (file)
@@ -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. */
index 5ca0d333d0b92dc84a6bc09040847cfbf0245abb..898b6e9067a45a26885c2948b075919350db439b 100644 (file)
@@ -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);