From 7322fbc37925671b3ac9e589ba8eb200b7aee7f3 Mon Sep 17 00:00:00 2001 Message-Id: <7322fbc37925671b3ac9e589ba8eb200b7aee7f3.1418766606.git.jen@redhat.com> In-Reply-To: <6f81b4847eb68ebdf54a8f1a771e19d112d74152.1418766606.git.jen@redhat.com> References: <6f81b4847eb68ebdf54a8f1a771e19d112d74152.1418766606.git.jen@redhat.com> From: Fam Zheng Date: Thu, 4 Dec 2014 00:04:57 -0600 Subject: [CHANGE 03/31] vmdk: Check VMFS extent line field number To: rhvirt-patches@redhat.com, jen@redhat.com RH-Author: Fam Zheng Message-id: <1417651524-18041-4-git-send-email-famz@redhat.com> Patchwork-id: 62676 O-Subject: [RHEL-7.1 qemu-kvm PATCH v5 03/30] vmdk: Check VMFS extent line field number Bugzilla: 1134237 RH-Acked-by: Jeffrey Cody RH-Acked-by: Markus Armbruster RH-Acked-by: Max Reitz VMFS extent line in description file should be with 4 fields: RW 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 Signed-off-by: Fam Zheng Signed-off-by: Stefan Hajnoczi (cherry picked from commit b47053bd0359c68094d7a25a65687c0844771e34) Signed-off-by: Fam Zheng Signed-off-by: Jeff E. Nelson --- block/vmdk.c | 9 +++++++-- tests/qemu-iotests/059 | 14 ++++++++++++++ tests/qemu-iotests/059.out | 5 +++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/block/vmdk.c b/block/vmdk.c index a5b1f1c..d77eb37 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -750,9 +750,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; } diff --git a/tests/qemu-iotests/059 b/tests/qemu-iotests/059 index 23534c2..c8d92a0 100755 --- a/tests/qemu-iotests/059 +++ b/tests/qemu-iotests/059 @@ -81,6 +81,20 @@ 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" <