From 80ee15a6b274dfcedb0ad7db8c9e7d392210d6a1 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Tue, 15 Sep 2009 12:30:43 +0200 Subject: qcow2: Increase maximum cluster size to 2 MB This patch increases the maximum qcow2 cluster size to 2 MB. Starting with 128k clusters, L2 tables span 2 GB or more of virtual disk space, causing 32 bit truncation and wraparound of signed integers. Therefore some variables need to use a larger data type. While being at reviewing data types, change some integers that are used for array indices to unsigned. In some places they were checked against some upper limit but not for negative values. This could avoid potential segfaults with corrupted qcow2 images. Signed-off-by: Kevin Wolf Signed-off-by: Anthony Liguori --- block/qcow2-refcount.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'block/qcow2-refcount.c') diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 0aac2edee1..609eee1891 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -192,7 +192,8 @@ static int64_t alloc_refcount_block(BlockDriverState *bs, int64_t cluster_index) { BDRVQcowState *s = bs->opaque; int64_t offset, refcount_block_offset; - int ret, refcount_table_index; + unsigned int refcount_table_index; + int ret; uint64_t data64; int cache = cache_refcount_updates; -- cgit v1.2.1