mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-08 02:03:56 -06:00
block: Fix error path segfault in bdrv_open()
Using an invalid option for a block device that is opened with BDRV_O_PROTOCOL led to drv = NULL, and when trying to include the driver name in the error message, qemu dereferenced it: $ x86_64-softmmu/qemu-system-x86_64 -drive file=/tmp/test.qcow2,file.foo=bar Segmentation fault (core dumped) With this patch applied, the expected error message is printed: $ x86_64-softmmu/qemu-system-x86_64 -drive file=/tmp/test.qcow2,file.foo=bar qemu-system-x86_64: -drive file=/tmp/test.qcow2,file.foo=bar: could not open disk image /tmp/test.qcow2: Block protocol 'file' doesn't support the option 'foo' Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Benoit Canet <benoit@irqsave.net>
This commit is contained in:
parent
c75203c8d3
commit
eb909c7f72
3 changed files with 25 additions and 0 deletions
|
@ -77,6 +77,15 @@ run_qemu -drive file="$TEST_IMG",format=qcow2,unknown_opt=on
|
|||
run_qemu -drive file="$TEST_IMG",format=qcow2,unknown_opt=1234
|
||||
run_qemu -drive file="$TEST_IMG",format=qcow2,unknown_opt=foo
|
||||
|
||||
echo
|
||||
echo === Unknown protocol option ===
|
||||
echo
|
||||
|
||||
run_qemu -drive file="$TEST_IMG",format=qcow2,file.unknown_opt=
|
||||
run_qemu -drive file="$TEST_IMG",format=qcow2,file.unknown_opt=on
|
||||
run_qemu -drive file="$TEST_IMG",format=qcow2,file.unknown_opt=1234
|
||||
run_qemu -drive file="$TEST_IMG",format=qcow2,file.unknown_opt=foo
|
||||
|
||||
echo
|
||||
echo === Invalid format ===
|
||||
echo
|
||||
|
|
|
@ -17,6 +17,21 @@ Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,unknown_opt=foo
|
|||
QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,unknown_opt=foo: could not open disk image TEST_DIR/t.qcow2: Block format 'qcow2' used by device 'ide0-hd0' doesn't support the option 'unknown_opt'
|
||||
|
||||
|
||||
=== Unknown protocol option ===
|
||||
|
||||
Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,file.unknown_opt=
|
||||
QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,file.unknown_opt=: could not open disk image TEST_DIR/t.qcow2: Block protocol 'file' doesn't support the option 'unknown_opt'
|
||||
|
||||
Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,file.unknown_opt=on
|
||||
QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,file.unknown_opt=on: could not open disk image TEST_DIR/t.qcow2: Block protocol 'file' doesn't support the option 'unknown_opt'
|
||||
|
||||
Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,file.unknown_opt=1234
|
||||
QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,file.unknown_opt=1234: could not open disk image TEST_DIR/t.qcow2: Block protocol 'file' doesn't support the option 'unknown_opt'
|
||||
|
||||
Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,file.unknown_opt=foo
|
||||
QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,file.unknown_opt=foo: could not open disk image TEST_DIR/t.qcow2: Block protocol 'file' doesn't support the option 'unknown_opt'
|
||||
|
||||
|
||||
=== Invalid format ===
|
||||
|
||||
Testing: -drive file=TEST_DIR/t.qcow2,format=foo
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue