1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-03-10 16:58:47 +03:00

lvmcmdline: enhance acceptance of size numbers

Explictely detect duplicate sing symbols and leave the rest of
double number validation on 'strtod()' function. This way
we can also accept size like:

lvcreate -L.1M

We already accept -L0.1M - but it's common to accept numbers
starting with leading '.' - just as 'strtod()' accepts it).
This commit is contained in:
Zdenek Kabelac 2017-07-16 10:30:07 +02:00
parent f7e62bc55c
commit 9b4b5d449e

View File

@ -560,8 +560,10 @@ static int _size_arg(struct cmd_context *cmd __attribute__((unused)),
av->sign = SIGN_NONE; av->sign = SIGN_NONE;
} }
if (!isdigit(*val)) if (*val == '+' || *val == '-') {
log_error("Multiple sign symbols detected.");
return 0; return 0;
}
errno = 0; errno = 0;
v = strtod(val, &ptr); v = strtod(val, &ptr);
@ -596,6 +598,7 @@ static int _size_arg(struct cmd_context *cmd __attribute__((unused)),
break; break;
if (i < 0) { if (i < 0) {
log_error("Can't parse size argument.");
return 0; return 0;
} else if (i == 7) { } else if (i == 7) {
/* v is already in sectors */ /* v is already in sectors */