]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
Bug 1230: Simple test case demonstrating failure.
authorJason Ish <jason.ish@emulex.com>
Mon, 29 Sep 2014 15:37:03 +0000 (09:37 -0600)
committerVictor Julien <victor@inliniac.net>
Mon, 20 Oct 2014 05:53:20 +0000 (07:53 +0200)
src/detect-within.c

index 9b35cbbc21483af4648ab71169fd8bdf8dd0dd53..cdea61142f6fb2351f4a86649d9b82a2bdb57833 100644 (file)
@@ -29,6 +29,7 @@
 #include "decode.h"
 
 #include "detect.h"
+#include "detect-engine.h"
 #include "detect-parse.h"
 #include "detect-content.h"
 #include "detect-uricontent.h"
@@ -246,6 +247,50 @@ end:
     return result;
 }
 
+static int DetectWithinTestVarSetup(void)
+{
+    DetectEngineCtx *de_ctx = NULL;
+    int result = 0;
+#if 1 /* FAILs */
+    char sig[] = "alert tcp any any -> any any ( "
+        "msg:\"test rule\"; "
+        "content:\"abc\"; "
+        "http_client_body; "
+        "byte_extract:2,0,somevar,relative; "
+        "content:\"def\"; "
+        "within:somevar; "
+        "http_client_body; "
+        "sid:4; rev:1;)";
+#else /* WORKs */
+    char sig[] = "alert tcp any any -> any any ( "
+        "msg:\"test rule\"; "
+        "content:\"abc\"; "
+        "http_client_body; "
+        "byte_extract:2,0,somevar,relative; "
+        "content:\"def\"; "
+        "http_client_body; "
+        "within:somevar; "
+        "sid:4; rev:1;)";
+#endif
+
+    de_ctx = DetectEngineCtxInit();
+    if (de_ctx == NULL) {
+        goto end;
+    }
+    de_ctx->sig_list = SigInit(de_ctx, sig);
+    if (de_ctx->sig_list == NULL) {
+        goto end;
+    }
+
+    result = 1;
+
+end:
+    SigGroupCleanup(de_ctx);
+    SigCleanSignatures(de_ctx);
+    DetectEngineCtxFree(de_ctx);
+
+    return result;
+}
 
 #endif /* UNITTESTS */
 
@@ -254,5 +299,6 @@ void DetectWithinRegisterTests(void)
     #ifdef UNITTESTS
     UtRegisterTest("DetectWithinTestPacket01", DetectWithinTestPacket01, 1);
     UtRegisterTest("DetectWithinTestPacket02", DetectWithinTestPacket02, 1);
+    UtRegisterTest("DetectWithinTestVarSetup", DetectWithinTestVarSetup, 1);
     #endif /* UNITTESTS */
 }