From e4ea3a1d5c7b3526a400312a615ffcaa2288d521 Mon Sep 17 00:00:00 2001 Message-Id: In-Reply-To: <8d77905c18814ff2e0c9d4336f80d2d8a8fd7250.1354535052.git.minovotn@redhat.com> References: <8d77905c18814ff2e0c9d4336f80d2d8a8fd7250.1354535052.git.minovotn@redhat.com> From: Kevin Wolf Date: Tue, 27 Nov 2012 09:43:57 +0100 Subject: [PATCH 3/4] qcow2: Fix refcount table size calculation RH-Author: Kevin Wolf Message-id: <1354009437-11336-1-git-send-email-kwolf@redhat.com> Patchwork-id: 44430 O-Subject: [RHEL-6.4 qemu-kvm PATCH] qcow2: Fix refcount table size calculation Bugzilla: 870917 RH-Acked-by: Miroslav Rezanina RH-Acked-by: Amos Kong RH-Acked-by: Vlad Yasevich RH-Acked-by: Stefan Hajnoczi Bugzilla: 870917 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 (cherry picked from commit a3548077062dd9dc2701ebffd931ba6eaef40bec) --- block/qcow2-refcount.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) Signed-off-by: Michal Novotny --- block/qcow2-refcount.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 74e1d49..5cdd98d 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.11.7