From: Jens Axboe Date: Sun, 27 Mar 2011 18:55:09 +0000 (+0200) Subject: Fix parser bug dealing with range options and postfix X-Git-Tag: fio-1.52~9 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=55ed9636e82b8dee419b5a76c07098bff4d980b6 Fix parser bug dealing with range options and postfix Signed-off-by: Jens Axboe --- diff --git a/parse.c b/parse.c index e9eb7385..585fb7e0 100644 --- a/parse.c +++ b/parse.c @@ -168,19 +168,20 @@ static unsigned long long __get_mult_bytes(const char *p, void *data) static unsigned long long get_mult_bytes(const char *str, int len, void *data) { - const char *p; + const char *p = str; if (len < 2) return __get_mult_bytes(str, data); - /* - * if the last char is 'b' or 'B', the user likely used - * "1gb" instead of just "1g". If the second to last is also - * a letter, adjust. - */ - p = str + len - 1; - while (isalpha(*(p - 1))) - p--; + /* + * Go forward until we hit a non-digit + */ + while ((p - str) <= len) { + if (!isdigit(*p)) + break; + p++; + } + if (!isalpha(*p)) p = NULL;