lib/strutils: parse_size() fix frac with zeros
Fix 0.001G as well as accept 0.000G as valid number. Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
5fcdf204b0
commit
482e0a0754
|
@ -122,13 +122,18 @@ check_suffix:
|
|||
|
||||
for (p = fstr; *p == '0'; p++)
|
||||
frac_zeros++;
|
||||
errno = 0, end = NULL;
|
||||
frac = strtoumax(fstr, &end, 0);
|
||||
if (end == fstr ||
|
||||
(errno != 0 && (frac == UINTMAX_MAX || frac == 0))) {
|
||||
rc = errno ? -errno : -EINVAL;
|
||||
goto err;
|
||||
}
|
||||
fstr = p;
|
||||
if (isdigit(*fstr)) {
|
||||
errno = 0, end = NULL;
|
||||
frac = strtoumax(fstr, &end, 0);
|
||||
if (end == fstr ||
|
||||
(errno != 0 && (frac == UINTMAX_MAX || frac == 0))) {
|
||||
rc = errno ? -errno : -EINVAL;
|
||||
goto err;
|
||||
}
|
||||
} else
|
||||
end = (char *) p;
|
||||
|
||||
if (frac && (!end || !*end)) {
|
||||
rc = -EINVAL;
|
||||
goto err; /* without suffix, but with frac */
|
||||
|
|
Loading…
Reference in New Issue