]> git.proxmox.com Git - mirror_qemu.git/commit - block/qcow2-refcount.c
qcow2: Fix alloc_clusters_noref() overflow detection
authorMax Reitz <mreitz@redhat.com>
Sun, 4 May 2014 03:31:40 +0000 (05:31 +0200)
committerStefan Hajnoczi <stefanha@redhat.com>
Fri, 9 May 2014 11:32:16 +0000 (13:32 +0200)
commit65f33bc0020112e7be7b8966495cd5efa2d0ab15
tree45cd51192d53cf9f20140c3e9bd253f47ab344e3
parent43cbeffb19877c62cbe0aaf08b2f235d98d71340
qcow2: Fix alloc_clusters_noref() overflow detection

If the very first allocation has a length of 0, the free_cluster_index
is still 0 after the for loop, which means that subtracting one from it
will underflow and signal an invalid range of clusters by returning
-EFBIG. However, there is no such range, as its length is 0.

Fix this by preventing underflows on free_cluster_index during the
check.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
block/qcow2-refcount.c