]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
stream_size operator comparison (fix issue #1488)
authorZopieux <Zopieux@users.noreply.github.com>
Thu, 18 Jun 2015 09:26:53 +0000 (11:26 +0200)
committerVictor Julien <victor@inliniac.net>
Wed, 8 Jul 2015 14:02:12 +0000 (16:02 +0200)
`DetectStreamSizeParse` was first checking if mode[0] is '<', which is true for both '<' and '<=', thus '<=' (and resp. '>=') is never matched. This patch does the `strcmp` to '<=' (resp. '>=') within the if block of '<' (resp. '>') to fix #1488.

src/detect-stream_size.c

index bec2edce6ef9ddc1fbc1a4aed3554db394324efe..c3eaad90f014d82af30953d9252317499ea0d6a0 100644 (file)
@@ -244,19 +244,19 @@ DetectStreamSizeData *DetectStreamSizeParse (char *streamstr)
     if (strlen(mode) == 0)
         goto error;
 
-    if (mode[0] == '<')
+    if (mode[0] == '=') {
+        sd->mode = DETECTSSIZE_EQ;
+    } else if (mode[0] == '<') {
         sd->mode = DETECTSSIZE_LT;
-    else if (strcmp("<=", mode) == 0)
-        sd->mode = DETECTSSIZE_LEQ;
-    else if (mode[0] == '>')
+        if (strcmp("<=", mode) == 0)
+            sd->mode = DETECTSSIZE_LEQ;
+    } else if (mode[0] == '>') {
         sd->mode = DETECTSSIZE_GT;
-    else if (strcmp(">=", mode) == 0)
-        sd->mode = DETECTSSIZE_GEQ;
-    else if (strcmp("!=", mode) == 0)
+        if (strcmp(">=", mode) == 0)
+            sd->mode = DETECTSSIZE_GEQ;
+    } else if (strcmp("!=", mode) == 0) {
         sd->mode = DETECTSSIZE_NEQ;
-    else if (mode[0] == '=')
-        sd->mode = DETECTSSIZE_EQ;
-    else {
+    } else {
         SCLogError(SC_ERR_INVALID_OPERATOR, "Invalid operator");
         goto error;
     }