]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
ParseSizeString - don't abort on unknown unit type. 1428/head
authorJason Ish <ish@unx.ca>
Thu, 16 Apr 2015 17:44:55 +0000 (11:44 -0600)
committerJason Ish <ish@unx.ca>
Thu, 16 Apr 2015 17:44:55 +0000 (11:44 -0600)
src/util-misc.c

index fdb3eaeae8c812447765a5bbd96747e5ebb14e43..b72aa05e8e6becab2c529c99831ff7bef142185d 100644 (file)
@@ -125,8 +125,9 @@ static int ParseSizeString(const char *size, double *res)
         } else if (strcasecmp(str2, "gb") == 0) {
             *res *= 1024 * 1024 * 1024;
         } else {
-            /* not possible */
-            BUG_ON(1);
+            /* Bad unit. */
+            retval = -1;
+            goto end;
         }
     }
 
@@ -1118,6 +1119,11 @@ int UtilMiscParseSizeStringTest01(void)
         goto error;
     }
 
+    /* Should fail on unknown units. */
+    if (ParseSizeString("32eb", &result) > 0) {
+        goto error;
+    }
+
     return 1;
  error:
     return 0;