]> git.ipfire.org Git - thirdparty/qemu.git/commit
qcow2-bitmap: Fix uint64_t left-shift overflow
authorTuguoyi <tu.guoyi@h3c.com>
Fri, 1 Nov 2019 07:37:35 +0000 (07:37 +0000)
committerMax Reitz <mreitz@redhat.com>
Thu, 7 Nov 2019 13:37:33 +0000 (14:37 +0100)
commit570542ecb11e04b61ef4b3f4d0965a6915232a88
tree07b1fc9169e7393641e2048d4cedd4f9c83b1275
parentd0f90e1423b4f412adc620eee93e8bfef8af4117
qcow2-bitmap: Fix uint64_t left-shift overflow

There are two issues in In check_constraints_on_bitmap(),
1) The sanity check on the granularity will cause uint64_t
integer left-shift overflow when cluster_size is 2M and the
granularity is BIGGER than 32K.
2) The way to calculate image size that the maximum bitmap
supported can map to is a bit incorrect.
This patch fix it by add a helper function to calculate the
number of bytes needed by a normal bitmap in image and compare
it to the maximum bitmap bytes supported by qemu.

Fixes: 5f72826e7fc62167cf3a
Signed-off-by: Guoyi Tu <tu.guoyi@h3c.com>
Message-id: 4ba40cd1e7ee4a708b40899952e49f22@h3c.com
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: Max Reitz <mreitz@redhat.com>
block/qcow2-bitmap.c