From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:59860) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TYhzu-0007nB-HX for qemu-devel@nongnu.org; Wed, 14 Nov 2012 13:47:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TYhzr-0000Qd-Er for qemu-devel@nongnu.org; Wed, 14 Nov 2012 13:47:38 -0500 Received: from mx1.redhat.com ([209.132.183.28]:14229) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TYhzr-0000QP-72 for qemu-devel@nongnu.org; Wed, 14 Nov 2012 13:47:35 -0500 From: Kevin Wolf Date: Wed, 14 Nov 2012 19:47:03 +0100 Message-Id: <1352918847-3696-3-git-send-email-kwolf@redhat.com> In-Reply-To: <1352918847-3696-1-git-send-email-kwolf@redhat.com> References: <1352918847-3696-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 02/26] qcow2: Fix refcount table size calculation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org A missing factor for the refcount table entry size in the calculation could mean that too little memory was allocated for the in-memory representation of the table, resulting in a buffer overflow. Signed-off-by: Kevin Wolf Reviewed-by: Michael Tokarev Tested-by: Michael Tokarev --- block/qcow2-refcount.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 5e3f915..96224d1 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -301,7 +301,8 @@ static int alloc_refcount_block(BlockDriverState *bs, uint64_t last_table_size; uint64_t blocks_clusters; do { - uint64_t table_clusters = size_to_clusters(s, table_size); + uint64_t table_clusters = + size_to_clusters(s, table_size * sizeof(uint64_t)); blocks_clusters = 1 + ((table_clusters + refcount_block_clusters - 1) / refcount_block_clusters); -- 1.7.6.5