]> sourceware.org Git - lvm2.git/commitdiff
lvmcmdline: enhance acceptance of size numbers
authorZdenek Kabelac <zkabelac@redhat.com>
Sun, 16 Jul 2017 08:30:07 +0000 (10:30 +0200)
committerZdenek Kabelac <zkabelac@redhat.com>
Mon, 17 Jul 2017 10:32:18 +0000 (12:32 +0200)
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).

tools/lvmcmdline.c

index 9cf2144883cf674504ae87bb414f45bd7d780fcd..3ff0d1d93cc4347f59ecce312920f01854fe67b9 100644 (file)
@@ -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 */
This page took 0.041596 seconds and 5 git commands to generate.