]> Git Repo - qemu.git/commitdiff
vmdk: Check VMFS extent line field number
authorFam Zheng <[email protected]>
Mon, 9 Dec 2013 05:24:36 +0000 (13:24 +0800)
committerStefan Hajnoczi <[email protected]>
Fri, 20 Dec 2013 08:11:58 +0000 (09:11 +0100)
VMFS extent line in description file should be with 4 fields:

    RW <size> VMFS "file-name.vmdk"

Check the number explicitly and report error if offset is appended as
FLAT, which should be invalid format.

Reported-by: Paolo Bonzini <[email protected]>
Signed-off-by: Fam Zheng <[email protected]>
Signed-off-by: Stefan Hajnoczi <[email protected]>
block/vmdk.c
tests/qemu-iotests/059
tests/qemu-iotests/059.out

index 0734bc200cef0622f9eb79faa7911832f48879ba..7917ad0c06f5e2136ed6b1a1805f8d2ed70a6fbc 100644 (file)
@@ -749,9 +749,14 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
                 return -EINVAL;
             }
         } else if (!strcmp(type, "VMFS")) {
-            flat_offset = 0;
+            if (ret == 4) {
+                flat_offset = 0;
+            } else {
+                error_setg(errp, "Invalid extent lines:\n%s", p);
+                return -EINVAL;
+            }
         } else if (ret != 4) {
-            error_setg(errp, "Invalid extent lines: \n%s", p);
+            error_setg(errp, "Invalid extent lines:\n%s", p);
             return -EINVAL;
         }
 
index 73941c3e61ba5f39d8c7ce3d2d78c9487a3154f1..65bea1d6c61c2443616d47ddddc9cc0e3903f708 100755 (executable)
@@ -80,6 +80,20 @@ echo "=== Testing big twoGbMaxExtentFlat ==="
 IMGOPTS="subformat=twoGbMaxExtentFlat" _make_test_img 1000G
 $QEMU_IMG info $TEST_IMG | _filter_testdir | sed -e 's/cid: [0-9]*/cid: XXXXXXXX/'
 
+echo
+echo "=== Testing malformed VMFS extent description line ==="
+cat >"$TEST_IMG" <<EOF
+# Disk DescriptorFile
+version=1
+CID=58ab4847
+parentCID=ffffffff
+createType="vmfs"
+
+# Extent description
+RW 12582912 VMFS "dummy.vmdk" 1
+EOF
+_img_info
+
 echo
 echo "=== Testing version 3 ==="
 _use_sample_img iotest-version3.vmdk.bz2
index 4ff935c6f40e9188403b7a430ace2044e2b2e782..16ab7c6c1f3196d521b640e2c658a75f73da9a63 100644 (file)
@@ -2038,6 +2038,11 @@ Format specific information:
             filename: TEST_DIR/t-f500.vmdk
             format: FLAT
 
+=== Testing malformed VMFS extent description line ===
+qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Invalid extent lines:
+RW 12582912 VMFS "dummy.IMGFMT" 1
+
+
 === Testing version 3 ===
 image: TEST_DIR/iotest-version3.IMGFMT
 file format: IMGFMT
This page took 0.03591 seconds and 4 git commands to generate.