qcow2-refcount: Catch array overflow
PATCH 1/1 qcow2-refcount: Catch array overflow
Add an assertion to alloc_refcount_block which catches an array index being out of bounds; this may occur if cluster_index is much too high (exceeding the image size). This in turn can be caused for instance by snapshotting a corrupted image (i.e., corrupted L2 tables).
Signed-off-by Max Reitz <[email protected]>
--- block/qcow2-refcount.c | 1 + 1 file changed, 1 insertion(+)
block/qcow2-refcount.c +1 -0
@@ -341,6 +341,7 @@ static int alloc_refcount_block(BlockDriverState *bs,/* Fill the new refcount table */ memcpy (new_table, s->refcount_table, s->refcount_table_size *sizeof (uint64_t )); +assert (refcount_table_index < table_size); new_table[refcount_table_index] = new_block;int i;
Signature · 1 line
1.8.3.1