From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60926) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y9H0T-00050X-Jg for qemu-devel@nongnu.org; Thu, 08 Jan 2015 12:36:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y9H04-0006wR-Ko for qemu-devel@nongnu.org; Thu, 08 Jan 2015 12:36:25 -0500 Received: from e31.co.us.ibm.com ([32.97.110.149]:57024) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y9H04-0006vW-3y for qemu-devel@nongnu.org; Thu, 08 Jan 2015 12:36:00 -0500 Received: from /spool/local by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 8 Jan 2015 10:35:59 -0700 From: Michael Roth Date: Thu, 8 Jan 2015 11:34:16 -0600 Message-Id: <1420738472-23267-73-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1420738472-23267-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1420738472-23267-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 72/88] qemu-img: Check create_opts before image amendment List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org From: Max Reitz 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 --- qemu-img.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/qemu-img.c b/qemu-img.c index 309c14b..27ac1fc 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -2775,6 +2775,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)) { -- 1.9.1