Skip to content

Commit 07ede68

Browse files
XanClicmdroth
authored andcommitted
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: [email protected] Signed-off-by: Max Reitz <[email protected]> Reviewed-by: Kevin Wolf <[email protected]> Signed-off-by: Kevin Wolf <[email protected]> (cherry picked from commit b2439d2) Signed-off-by: Michael Roth <[email protected]>
1 parent 2fbad1f commit 07ede68

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

qemu-img.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2775,6 +2775,13 @@ static int img_amend(int argc, char **argv)
27752775
goto out;
27762776
}
27772777

2778+
if (!bs->drv->create_opts) {
2779+
error_report("Format driver '%s' does not support any options to amend",
2780+
fmt);
2781+
ret = -1;
2782+
goto out;
2783+
}
2784+
27782785
create_opts = qemu_opts_append(create_opts, bs->drv->create_opts);
27792786
opts = qemu_opts_create(create_opts, NULL, 0, &error_abort);
27802787
if (options && qemu_opts_do_parse(opts, options, NULL)) {

0 commit comments

Comments
 (0)