From patchwork Wed Mar 26 12:05:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 333913 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 7118E14008C for ; Thu, 27 Mar 2014 00:47:24 +1100 (EST) Received: from localhost ([::1]:47383 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WSmdf-0003hY-He for incoming@patchwork.ozlabs.org; Wed, 26 Mar 2014 08:08:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49936) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WSmbS-0000s8-VZ for qemu-devel@nongnu.org; Wed, 26 Mar 2014 08:06:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WSmbM-0003x5-Ql for qemu-devel@nongnu.org; Wed, 26 Mar 2014 08:06:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:9525) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WSmbM-0003ww-JQ; Wed, 26 Mar 2014 08:06:36 -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 s2QC6Z29006019 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 26 Mar 2014 08:06:35 -0400 Received: from localhost (dhcp-64-106.muc.redhat.com [10.32.64.106]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s2QC6YE6014387; Wed, 26 Mar 2014 08:06:35 -0400 From: Stefan Hajnoczi To: Date: Wed, 26 Mar 2014 13:05:35 +0100 Message-Id: <1395835569-21193-14-git-send-email-stefanha@redhat.com> In-Reply-To: <1395835569-21193-1-git-send-email-stefanha@redhat.com> References: <1395835569-21193-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , pmatouse@redhat.com, qemu-stable@nongnu.org Subject: [Qemu-devel] [PATCH for-2.0 13/47] bochs: Fix bitmap offset calculation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Kevin Wolf 32 bit truncation could let us access the wrong offset in the image. Signed-off-by: Kevin Wolf Reviewed-by: Stefan Hajnoczi Reviewed-by: Max Reitz --- block/bochs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/block/bochs.c b/block/bochs.c index a922782..826ec12 100644 --- a/block/bochs.c +++ b/block/bochs.c @@ -186,8 +186,9 @@ static int64_t seek_to_sector(BlockDriverState *bs, int64_t sector_num) return -1; /* not allocated */ } - bitmap_offset = s->data_offset + (512 * s->catalog_bitmap[extent_index] * - (s->extent_blocks + s->bitmap_blocks)); + bitmap_offset = s->data_offset + + (512 * (uint64_t) s->catalog_bitmap[extent_index] * + (s->extent_blocks + s->bitmap_blocks)); /* read in bitmap for current extent */ if (bdrv_pread(bs->file, bitmap_offset + (extent_offset / 8),