From: Max Reitz Date: Tue, 2 Dec 2014 17:32:47 +0000 (+0100) Subject: qemu-img: Check create_opts before image amendment X-Git-Tag: qemu-xen-4.6.0-rc1~34^2~48 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=b15bfd0558934703cfa860117a38d7f0a71645ae;p=qemu-upstream-4.6-testing.git qemu-img: Check create_opts before image amendment The image options which can be amended are described by the .create_opts field for every driver. This field must therefore be non-NULL so that anything can be amended in the first place. Check that this holds true before going into qemu_opts_create() (because if .create_opts is NULL, the create_opts pointer in img_amend() will be NULL after qemu_opts_append()). Cc: qemu-stable@nongnu.org Signed-off-by: Max Reitz Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf (cherry picked from commit b2439d26f078c826e5e06b34d978a6f6d5c7c56f) Signed-off-by: Michael Roth --- diff --git a/qemu-img.c b/qemu-img.c index 8c4edf37a..7876258fa 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -2986,6 +2986,13 @@ static int img_amend(int argc, char **argv) goto out; } + if (!bs->drv->create_opts) { + error_report("Format driver '%s' does not support any options to amend", + fmt); + ret = -1; + goto out; + } + create_opts = qemu_opts_append(create_opts, bs->drv->create_opts); opts = qemu_opts_create(create_opts, NULL, 0, &error_abort); if (options && qemu_opts_do_parse(opts, options, NULL)) {