From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50492) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vu2IU-0004mI-CO for qemu-devel@nongnu.org; Fri, 20 Dec 2013 10:47:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vu2IO-0000bl-Bo for qemu-devel@nongnu.org; Fri, 20 Dec 2013 10:47:30 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47572) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vu2IO-0000ZT-3I for qemu-devel@nongnu.org; Fri, 20 Dec 2013 10:47:24 -0500 From: Stefan Hajnoczi Date: Fri, 20 Dec 2013 16:46:48 +0100 Message-Id: <1387554416-5837-11-git-send-email-stefanha@redhat.com> In-Reply-To: <1387554416-5837-1-git-send-email-stefanha@redhat.com> References: <1387554416-5837-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PULL 10/18] vmdk: Check VMFS extent line field number List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Anthony Liguori From: Fam Zheng 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 --- 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 0734bc2..7917ad0 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -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; } diff --git a/tests/qemu-iotests/059 b/tests/qemu-iotests/059 index 73941c3..65bea1d 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" <