]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: Back out if the argument for vol-create-as is malformed
authorOsier Yang <jyang@redhat.com>
Mon, 4 Jun 2012 09:08:34 +0000 (17:08 +0800)
committerCole Robinson <crobinso@redhat.com>
Thu, 14 Jun 2012 22:38:26 +0000 (18:38 -0400)
(cherry picked from commit ee58b581c4b275f06904253285b7ad562dc09745)

Conflicts:

tools/virsh.c

tools/virsh.c

index 61d530762e84a4635863bf0262d684c07dbb7f63..31d784cecea80ce914271702f47cbd9b7d45678b 100644 (file)
@@ -11121,18 +11121,24 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
 
     if (vshCommandOptString(cmd, "capacity", &capacityStr) <= 0)
         goto cleanup;
-    if (vshVolSize(capacityStr, &capacity) < 0)
+
+    if (vshVolSize(capacityStr, &capacity) < 0) {
         vshError(ctl, _("Malformed size %s"), capacityStr);
+        goto cleanup;
+    }
 
-    if ((vshCommandOptString(cmd, "allocation", &allocationStr) > 0) &&
-        (vshVolSize(allocationStr, &allocation) < 0))
+    if (vshCommandOptString(cmd, "allocation", &allocationStr) > 0 &&
+        vshVolSize(allocationStr, &allocation) < 0) {
         vshError(ctl, _("Malformed size %s"), allocationStr);
+        goto cleanup;
+    }
 
     if (vshCommandOptString(cmd, "format", &format) < 0 ||
         vshCommandOptString(cmd, "backing-vol", &snapshotStrVol) < 0 ||
         vshCommandOptString(cmd, "backing-vol-format",
                             &snapshotStrFormat) < 0) {
         vshError(ctl, "%s", _("missing argument"));
+        goto cleanup;
     }