]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect/content: Validate content byte array
authorJeff Lucovsky <jeff@lucovsky.org>
Thu, 11 Jun 2020 13:08:42 +0000 (09:08 -0400)
committerVictor Julien <victor@inliniac.net>
Mon, 29 Jun 2020 18:23:05 +0000 (20:23 +0200)
This commit checks whether the content byte array is compatible with the
transforms, if any, for the rule.

src/detect-content.c

index 7ab5ba6e12b64e2acca87d16b7dca94075fc8293..bfadd6ddc6dbc35e7d80b51ce2430eea7b2f7da5 100644 (file)
@@ -335,6 +335,17 @@ int DetectContentSetup(DetectEngineCtx *de_ctx, Signature *s, const char *conten
     int sm_list = s->init_data->list;
     if (sm_list == DETECT_SM_LIST_NOTSET) {
         sm_list = DETECT_SM_LIST_PMATCH;
+    } else if (sm_list > DETECT_SM_LIST_MAX &&
+            0 == (cd->flags & DETECT_CONTENT_NEGATED)) {
+        /* Check transform compatibility */
+        const char *tstr;
+        if (!DetectBufferTypeValidateTransform(de_ctx, sm_list, cd->content,
+                    cd->content_len, &tstr)) {
+            SCLogError(SC_ERR_INVALID_SIGNATURE,
+                    "content string \"%s\" incompatible with %s transform",
+                    contentstr, tstr);
+            goto error;
+        }
     }
 
     sm = SigMatchAlloc();