From ca60d8c370ca3675d840b07f35a70095b966f0ff Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Thu, 16 Apr 2015 11:44:55 -0600 Subject: [PATCH] ParseSizeString - don't abort on unknown unit type. --- src/util-misc.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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; -- 2.47.2