]> sourceware.org Git - lvm2.git/commitdiff
lvcreate: validate sizes
authorZdenek Kabelac <zkabelac@redhat.com>
Mon, 6 Oct 2014 11:54:34 +0000 (13:54 +0200)
committerZdenek Kabelac <zkabelac@redhat.com>
Mon, 6 Oct 2014 13:23:07 +0000 (15:23 +0200)
Earlier validation of --size and --extents.
Reject 0 size on command line instantly.

tools/lvcreate.c

index 0a0ce1d8c16d313c871d6f1aaa18ee2fb561a8ec..97c8d9457726eaeda2be78728ea8c097f6c8a928 100644 (file)
@@ -506,20 +506,26 @@ static int _read_size_params(struct lvcreate_params *lp,
 
        if (arg_count(cmd, extents_ARG)) {
                if (arg_sign_value(cmd, extents_ARG, SIGN_NONE) == SIGN_MINUS) {
-                       log_error("Negative number of extents is invalid");
+                       log_error("Negative number of extents is invalid.");
+                       return 0;
+               }
+               if (!(lp->extents = arg_uint_value(cmd, extents_ARG, 0))) {
+                       log_error("Number of extents may not be zero.");
                        return 0;
                }
-               lp->extents = arg_uint_value(cmd, extents_ARG, 0);
                lcp->percent = arg_percent_value(cmd, extents_ARG, PERCENT_NONE);
        }
 
        /* Size returned in kilobyte units; held in sectors */
        if (arg_count(cmd, size_ARG)) {
                if (arg_sign_value(cmd, size_ARG, SIGN_NONE) == SIGN_MINUS) {
-                       log_error("Negative size is invalid");
+                       log_error("Negative size is invalid.");
+                       return 0;
+               }
+               if (!(lcp->size = arg_uint64_value(cmd, size_ARG, UINT64_C(0)))) {
+                       log_error("Size may not be zero.");
                        return 0;
                }
-               lcp->size = arg_uint64_value(cmd, size_ARG, UINT64_C(0));
                lcp->percent = PERCENT_NONE;
        }
 
This page took 0.037023 seconds and 5 git commands to generate.