Skip to content

Commit

Permalink
qemu-img: Check create_opts before image amendment
Browse files Browse the repository at this point in the history
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 <mreitz@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
  • Loading branch information
XanClic authored and kevmw committed Dec 10, 2014
1 parent f75613c commit b2439d2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions qemu-img.c
Expand Up @@ -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)) {
Expand Down

0 comments on commit b2439d2

Please sign in to comment.