From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48486) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xu0NU-0000Ue-KC for qemu-devel@nongnu.org; Thu, 27 Nov 2014 09:49:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xu0NP-0003Xh-CT for qemu-devel@nongnu.org; Thu, 27 Nov 2014 09:49:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45520) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xu0NP-0003XU-5Z for qemu-devel@nongnu.org; Thu, 27 Nov 2014 09:48:59 -0500 From: Max Reitz Date: Thu, 27 Nov 2014 15:48:34 +0100 Message-Id: <1417099720-16428-8-git-send-email-mreitz@redhat.com> In-Reply-To: <1417099720-16428-1-git-send-email-mreitz@redhat.com> References: <1417099720-16428-1-git-send-email-mreitz@redhat.com> Subject: [Qemu-devel] [PATCH v2 07/13] 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: Kevin Wolf , Peter Lieven , Markus Armbruster , Max Reitz , Stefan Hajnoczi 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 --- qemu-img.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/qemu-img.c b/qemu-img.c index 8c4edf3..7876258 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)) { -- 1.9.3