From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46631) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YmmVb-0007OG-K5 for qemu-devel@nongnu.org; Mon, 27 Apr 2015 13:07:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YmmVY-0003DZ-Cl for qemu-devel@nongnu.org; Mon, 27 Apr 2015 13:07:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58416) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YmmVY-0003DN-5C for qemu-devel@nongnu.org; Mon, 27 Apr 2015 13:07:48 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t3RH7lgE030065 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Mon, 27 Apr 2015 13:07:47 -0400 Message-ID: <553E6CE2.6050502@redhat.com> Date: Mon, 27 Apr 2015 13:07:46 -0400 From: John Snow MIME-Version: 1.0 References: <1430144581-9803-1-git-send-email-famz@redhat.com> In-Reply-To: <1430144581-9803-1-git-send-email-famz@redhat.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] vmdk: Widen before shifting 32 bit header field List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng , qemu-devel@nongnu.org Cc: Kevin Wolf , armbru@redhat.com, Stefan Hajnoczi On 04/27/2015 10:23 AM, Fam Zheng wrote: > 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, > Reviewed-by: John Snow