From 4b5a793070ab6d961224c5e9f23b65e64c7ff6ae Mon Sep 17 00:00:00 2001 From: Osier Yang Date: Mon, 4 Jun 2012 17:08:34 +0800 Subject: [PATCH] virsh: Back out if the argument for vol-create-as is malformed (cherry picked from commit ee58b581c4b275f06904253285b7ad562dc09745) Conflicts: tools/virsh.c --- tools/virsh.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tools/virsh.c b/tools/virsh.c index 61d530762e..31d784cece 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -11121,18 +11121,24 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptString(cmd, "capacity", &capacityStr) <= 0) goto cleanup; - if (vshVolSize(capacityStr, &capacity) < 0) - vshError(ctl, _("Malformed size %s"), capacityStr); - if ((vshCommandOptString(cmd, "allocation", &allocationStr) > 0) && - (vshVolSize(allocationStr, &allocation) < 0)) + if (vshVolSize(capacityStr, &capacity) < 0) { + vshError(ctl, _("Malformed size %s"), capacityStr); + goto cleanup; + } + + 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; }