qcow2: Prevent allocating compressed clusters at offset 0
commit8aa34834d566ba4e635d6029339a5f4f1ae1685e
authorAlberto Garcia <berto@igalia.com>
Fri, 3 Nov 2017 14:18:52 +0000 (3 16:18 +0200)
committerMax Reitz <mreitz@redhat.com>
Tue, 14 Nov 2017 17:06:25 +0000 (14 18:06 +0100)
tree8708d307c07eb4f467d34f6bd0378234b6850792
parent9883975050deffc147a3903d07ff995ecdc8a100
qcow2: Prevent allocating compressed clusters at offset 0

If the refcount data is corrupted then we can end up trying to
allocate a new compressed cluster at offset 0 in the image, triggering
an assertion in qcow2_alloc_bytes() that would crash QEMU:

  qcow2_alloc_bytes: Assertion `offset' failed.

This patch adds an explicit check for this scenario and a new test
case.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Message-id: fb53467cf48e95ff3330def1cf1003a5b862b7d9.1509718618.git.berto@igalia.com
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
block/qcow2-refcount.c
tests/qemu-iotests/060
tests/qemu-iotests/060.out