mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
qcow2: Fix backing file name length check
len could become negative and would pass the check then. Nothing bad happened because bdrv_pread() happens to return an error for negative length values, but make variables for sizes unsigned anyway. This patch also changes the behaviour to error out on invalid lengths instead of silently truncating it to 1023. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
2d51c32c4b
commit
6d33e8e7dc
3 changed files with 19 additions and 3 deletions
|
@ -45,6 +45,7 @@ _supported_os Linux
|
|||
header_size=104
|
||||
|
||||
offset_backing_file_offset=8
|
||||
offset_backing_file_size=16
|
||||
offset_l1_size=36
|
||||
offset_l1_table_offset=40
|
||||
offset_refcount_table_offset=48
|
||||
|
@ -135,6 +136,13 @@ poke_file "$TEST_IMG" "$offset_l1_table_offset" "\x12\x34\x56\x78\x90\xab\xcd\xe
|
|||
poke_file "$TEST_IMG" "$offset_l1_size" "\x00\x00\x00\x01"
|
||||
{ $QEMU_IO -c "read 0 512" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir
|
||||
|
||||
echo
|
||||
echo "== Invalid backing file size =="
|
||||
_make_test_img 64M
|
||||
poke_file "$TEST_IMG" "$offset_backing_file_offset" "\x00\x00\x00\x00\x00\x00\x10\x00"
|
||||
poke_file "$TEST_IMG" "$offset_backing_file_size" "\xff\xff\xff\xff"
|
||||
{ $QEMU_IO -c "read 0 512" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir
|
||||
|
||||
# success, all done
|
||||
echo "*** done"
|
||||
rm -f $seq.full
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue