]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
qcow2: Assert against currently impossible overflow
authorMax Reitz <mreitz@redhat.com>
Wed, 25 Sep 2013 15:48:55 +0000 (17:48 +0200)
committerKevin Wolf <kwolf@redhat.com>
Wed, 25 Sep 2013 19:57:44 +0000 (21:57 +0200)
If qcow2_alloc_cluster_link_l2 is called with a QCowL2Meta describing a
request crossing L2 boundaries, a buffer overflow will occur. This is
impossible right now since such requests are never generated (every
request is shortened to L2 boundaries before) and probably also
completely unintended (considering the name "QCowL2Meta"), however, it
is still worth an assertion.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/qcow2-cluster.c

index 738ff73c1d0be9bb3800769bf82cb4a8a56675a7..cab5f2e6b592bb6850ba6da9332c5ec578cb96a3 100644 (file)
@@ -716,6 +716,7 @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, QCowL2Meta *m)
     }
     qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table);
 
+    assert(l2_index + m->nb_clusters <= s->l2_size);
     for (i = 0; i < m->nb_clusters; i++) {
         /* if two concurrent writes happen to the same unallocated cluster
         * each write allocates separate cluster and writes data concurrently.