]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
mpm/hs: track maxdepth
authorVictor Julien <victor@inliniac.net>
Fri, 22 Mar 2019 19:18:44 +0000 (20:18 +0100)
committerVictor Julien <victor@inliniac.net>
Tue, 26 Mar 2019 08:23:22 +0000 (09:23 +0100)
src/util-mpm-hs.c

index eca73f7cba98435cb3e64b0e87537adf181922ba..194a7bbd783c1b786cbce5f1d17dbb12d9d1f7e2 100644 (file)
@@ -313,6 +313,17 @@ static int SCHSAddPattern(MpmCtx *mpm_ctx, uint8_t *pat, uint16_t patlen,
 
         mpm_ctx->pattern_cnt++;
 
+        if (!(mpm_ctx->flags & MPMCTX_FLAGS_NODEPTH)) {
+            if (depth) {
+                mpm_ctx->maxdepth = MAX(mpm_ctx->maxdepth, depth);
+                SCLogDebug("%p: depth %u max %u", mpm_ctx, depth, mpm_ctx->maxdepth);
+            } else {
+                mpm_ctx->flags |= MPMCTX_FLAGS_NODEPTH;
+                mpm_ctx->maxdepth = 0;
+                SCLogDebug("%p: alas, no depth for us", mpm_ctx);
+            }
+        }
+
         if (mpm_ctx->maxlen < patlen)
             mpm_ctx->maxlen = patlen;