mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +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:
parent
f7e62bc55c
commit
9b4b5d449e
@ -560,8 +560,10 @@ static int _size_arg(struct cmd_context *cmd __attribute__((unused)),
|
||||
av->sign = SIGN_NONE;
|
||||
}
|
||||
|
||||
if (!isdigit(*val))
|
||||
if (*val == '+' || *val == '-') {
|
||||
log_error("Multiple sign symbols detected.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
errno = 0;
|
||||
v = strtod(val, &ptr);
|
||||
@ -596,6 +598,7 @@ static int _size_arg(struct cmd_context *cmd __attribute__((unused)),
|
||||
break;
|
||||
|
||||
if (i < 0) {
|
||||
log_error("Can't parse size argument.");
|
||||
return 0;
|
||||
} else if (i == 7) {
|
||||
/* v is already in sectors */
|
||||
|
Loading…
Reference in New Issue
Block a user