From: Max Reitz Date: Fri, 7 Mar 2014 22:10:12 +0000 (+0100) Subject: qcow2-refcount: Sanitize refcount table entry X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~386^2~42^2~93^2~23 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=26d49c46750aff62c8c6e7a8b14c79d4114a8e53;p=sdk%2Femulator%2Fqemu.git qcow2-refcount: Sanitize refcount table entry When reading the refcount table entry in get_refcount(), only bits which are actually significant for the refcount block offset should be taken into account. Signed-off-by: Max Reitz Reviewed-by: Laszlo Ersek Signed-off-by: Stefan Hajnoczi --- diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 8712d8bd54..6151148507 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -96,7 +96,8 @@ static int get_refcount(BlockDriverState *bs, int64_t cluster_index) refcount_table_index = cluster_index >> (s->cluster_bits - REFCOUNT_SHIFT); if (refcount_table_index >= s->refcount_table_size) return 0; - refcount_block_offset = s->refcount_table[refcount_table_index]; + refcount_block_offset = + s->refcount_table[refcount_table_index] & REFT_OFFSET_MASK; if (!refcount_block_offset) return 0;