]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rule parser: fix crashing on malformed options
authorVictor Julien <victor@inliniac.net>
Fri, 19 Sep 2014 11:38:47 +0000 (13:38 +0200)
committerVictor Julien <victor@inliniac.net>
Fri, 19 Sep 2014 11:38:47 +0000 (13:38 +0200)
Fix crashing on malformed rule options like 'rev;1;'.

Bug 1254.

src/detect-parse.c

index e1a9b3026d1bbaad373e85cae4762f4642866b47..1a5d683b25e188ba2bb57b0d85ad628f1f80e7eb 100644 (file)
@@ -552,6 +552,14 @@ static int SigParseOptions(DetectEngineCtx *de_ctx, Signature *s, char *optstr,
         }
     }
 
+    if (!(st->flags & SIGMATCH_NOOPT)) {
+        if (strlen(optvalue) == 0) {
+            SCLogError(SC_ERR_INVALID_SIGNATURE, "invalid formatting or malformed option to %s keyword: \'%s\'",
+                    optname, optstr);
+            goto error;
+        }
+    }
+
     /* setup may or may not add a new SigMatch to the list */
     if (st->Setup(de_ctx, s, strlen(optvalue) ? optvalue : NULL) < 0) {
         SCLogDebug("\"%s\" failed to setup", st->name);