From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50378) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YmjwE-0001dP-Lr for qemu-devel@nongnu.org; Mon, 27 Apr 2015 10:23:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YmjwB-0006BD-F8 for qemu-devel@nongnu.org; Mon, 27 Apr 2015 10:23:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60742) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YmjwB-0006B9-7L for qemu-devel@nongnu.org; Mon, 27 Apr 2015 10:23:07 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t3REN6iT009122 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Mon, 27 Apr 2015 10:23:06 -0400 From: Fam Zheng Date: Mon, 27 Apr 2015 22:23:01 +0800 Message-Id: <1430144581-9803-1-git-send-email-famz@redhat.com> Subject: [Qemu-devel] [PATCH] vmdk: Widen before shifting 32 bit header field List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Fam Zheng , armbru@redhat.com, Stefan Hajnoczi 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 --- block/vmdk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/vmdk.c b/block/vmdk.c index 8410a15..d72a6e8 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -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, -- 1.9.3