Fix parser using uninitialized memory
[fio.git] / parse.c
diff --git a/parse.c b/parse.c
index 445812159585cf1dc490f6a294e278dbe4d2ffca..25de29e2a84eb51605562b355869d3006bdec632 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -192,10 +192,10 @@ static unsigned long long get_mult_bytes(const char *str, int len, void *data,
                return __get_mult_bytes(str, data, percent);
 
         /*
-         * Go forward until we hit a non-digit
+         * Go forward until we hit a non-digit, or +/- sign
          */
        while ((p - str) <= len) {
-               if (!isdigit((int) *p))
+               if (!isdigit((int) *p) && (*p != '+') && (*p != '-'))
                        break;
                p++;
        }
@@ -489,6 +489,9 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data,
 
                posval_sort(o, posval);
 
+               if (!o->posval[0].ival)
+                       goto match;
+
                ret = 1;
                for (i = 0; i < PARSE_MAX_VP; i++) {
                        vp = &posval[i];
@@ -501,6 +504,7 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data,
                                ret = 0;
                                if (vp->cb)
                                        fn = vp->cb;
+match:
                                if (o->roff1)
                                        cp = (char **) o->roff1;
                                else