Fix improper behaviour of parse_bytes when string contains only one letter 94/227094/4
authorAgnieszka Baumann <a.baumann@samsung.com>
Mon, 9 Mar 2020 14:13:16 +0000 (15:13 +0100)
committerMichal Bloch <m.bloch@partner.samsung.com>
Fri, 13 Mar 2020 12:13:33 +0000 (12:13 +0000)
Change-Id: Ie50ff0a666eedf4396f9e78d3d3aff07d9802885

src/common/util.c

index c1ae720..1cdcbfb 100644 (file)
@@ -140,7 +140,7 @@ int parse_bytes(const char *b, size_t *s)
                return 0;
 
        num_l = strspn(b, "0123456789");
-       if (num_l < len-1)
+       if ((num_l < len-1) || num_l == 0)
                return -EINVAL;
 
        unit_l = strcspn(b, "BKMG");