]> 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)
committerOsier Yang <jyang@redhat.com>
Tue, 5 Jun 2012 06:56:40 +0000 (14:56 +0800)
tools/virsh.c

index 260a0be2200c5c662883e79d38c78a4fc8e8a2b8..abcfbffa388d36bdc56049abf7cf9aeaabdda4a7 100644 (file)
@@ -11372,18 +11372,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)
+        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;
     }