]> git.proxmox.com Git - mirror_qemu.git/commitdiff
vmdk: Widen before shifting 32 bit header field
authorFam Zheng <famz@redhat.com>
Mon, 27 Apr 2015 14:23:01 +0000 (22:23 +0800)
committerKevin Wolf <kwolf@redhat.com>
Tue, 28 Apr 2015 13:36:11 +0000 (15:36 +0200)
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 <famz@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/vmdk.c

index fd94b8f605de7c3d706434879ad465b7e6a765d2..1c5e2ef1b3852d726607aba225365ff774e68a56 100644 (file)
@@ -523,7 +523,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,