vmdk: check granularity field in opening

Granularity is used to calculate the cluster size and allocate r/w
buffer. Check the value from image before using it, so we don't abort()
for unbounded memory allocation.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
Fam Zheng 2013-08-06 15:44:51 +08:00 committed by Kevin Wolf
parent ca6cbb657d
commit 8aa1331c09
3 changed files with 44 additions and 10 deletions

View file

@ -43,7 +43,13 @@ _supported_fmt vmdk
_supported_proto generic
_supported_os Linux
granularity_offset=16
granularity_offset=20
echo "=== Testing invalid granularity ==="
echo
_make_test_img 64M
poke_file "$TEST_IMG" "$granularity_offset" "\xff\xff\xff\xff\xff\xff\xff\xff"
{ $QEMU_IO -c "read 0 512" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir
# success, all done
echo "*** done"

View file

@ -1,2 +1,8 @@
QA output created by 059
=== Testing invalid granularity ===
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
invalid granularity, image may be corrupt
qemu-io: can't open device TEST_DIR/t.vmdk
no file open, try 'help open'
*** done