summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2012-10-26 16:33:32 +0200
committerDoug Goldstein <cardoe@cardoe.com>2012-12-13 15:31:59 -0600
commit3a120fd037150422cd1be61bc888617a78104719 (patch)
tree7899cbd592bc1c008eeac4ef760a1009b6563ed5
parentconfigure: avoid compiler warning in pipe2 detection (diff)
downloadqemu-kvm-3a120fd037150422cd1be61bc888617a78104719.tar.gz
qemu-kvm-3a120fd037150422cd1be61bc888617a78104719.tar.bz2
qemu-kvm-3a120fd037150422cd1be61bc888617a78104719.zip
qcow2: Fix refcount table size calculation
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 <kwolf@redhat.com> Reviewed-by: Michael Tokarev <mjt@tls.msk.ru> Tested-by: Michael Tokarev <mjt@tls.msk.ru> (cherry picked from commit a3548077062dd9dc2701ebffd931ba6eaef40bec) Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com> (cherry picked from commit 600a9efdb1ddb749332200cab27d9240fbc0bda1)
-rw-r--r--block/qcow2-refcount.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
index 5e3f9153f..96224d1af 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);