From: Jason Ish Date: Thu, 16 Apr 2015 17:44:55 +0000 (-0600) Subject: ParseSizeString - don't abort on unknown unit type. X-Git-Tag: suricata-2.1beta4~62 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F1428%2Fhead;p=thirdparty%2Fsuricata.git ParseSizeString - don't abort on unknown unit type. --- diff --git a/src/util-misc.c b/src/util-misc.c index fdb3eaeae8..b72aa05e8e 100644 --- a/src/util-misc.c +++ b/src/util-misc.c @@ -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;