From 649835536d4bb1366e01ff5600d3005042dd50d5 Mon Sep 17 00:00:00 2001 From: Fam Zheng Date: Mon, 15 Feb 2016 09:28:24 +0100 Subject: [PATCH 11/18] vmdk: Widen before shifting 32 bit header field RH-Author: Fam Zheng Message-id: <1455528511-9357-12-git-send-email-famz@redhat.com> Patchwork-id: 69177 O-Subject: [RHEL-7.3 qemu-kvm PATCH 11/18] vmdk: Widen before shifting 32 bit header field Bugzilla: 1299250 RH-Acked-by: Kevin Wolf RH-Acked-by: Max Reitz RH-Acked-by: Markus Armbruster BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1299250 Coverity spotted this. The field is 32 bits, but if it's possible to overflow in 32 bit left shift. Signed-off-by: Fam Zheng Reviewed-by: John Snow Signed-off-by: Kevin Wolf (cherry picked from commit 7237aecd7e8fcc3ccf7fded77b6c127b4df5d3ac) Signed-off-by: Fam Zheng Signed-off-by: Miroslav Rezanina --- block/vmdk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/vmdk.c b/block/vmdk.c index 32b3d4c..3810d75 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -525,7 +525,7 @@ static int vmdk_open_vmfs_sparse(BlockDriverState *bs, } ret = vmdk_add_extent(bs, file, false, le32_to_cpu(header.disk_sectors), - le32_to_cpu(header.l1dir_offset) << 9, + (int64_t)le32_to_cpu(header.l1dir_offset) << 9, 0, le32_to_cpu(header.l1dir_size), 4096, -- 1.8.3.1