From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:56844) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TRpnJ-0002bs-LC for qemu-devel@nongnu.org; Fri, 26 Oct 2012 15:42:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TRpnI-0004Z5-PL for qemu-devel@nongnu.org; Fri, 26 Oct 2012 15:42:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59011) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TRpnI-0004Yv-HS for qemu-devel@nongnu.org; Fri, 26 Oct 2012 15:42:12 -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 q9QJgBmO026856 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 26 Oct 2012 15:42:12 -0400 From: Kevin Wolf Date: Fri, 26 Oct 2012 21:42:07 +0200 Message-Id: <1351280528-21889-2-git-send-email-kwolf@redhat.com> In-Reply-To: <1351280528-21889-1-git-send-email-kwolf@redhat.com> References: <1351280528-21889-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 1/2] qcow2: Fix refcount table size calculation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com 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 --- 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