On 06/20/2016 08:26 AM, Max Reitz wrote: > Recently, qcow2_get_cluster_offset() has been changed to work with bytes > instead of sectors. This invalidated some assertions and introduced a > possible integer multiplication overflow. > > This could be reproduced using e.g. > > $ qemu-img create -f qcow2 -o cluster_size=1M blub.qcow2 8G > Formatting 'foo.qcow2', fmt=qcow2 size=8589934592 encryption=off > cluster_size=1048576 lazy_refcounts=off refcount_bits=16 > $ qemu-io -c map blub.qcow2 > qemu-io: qemu/block/qcow2-cluster.c:504: qcow2_get_cluster_offset: > Assertion `bytes_needed <= INT_MAX' failed. > [1] 20775 abort (core dumped) qemu-io -c map foo.qcow2 > > This patch removes the now wrong assertion, adding comments and more > assertions to prove its correctness (and fixing the overflow which would > become apparent with the original assertion removed). > > Signed-off-by: Max Reitz <mre...@redhat.com> > --- > block/qcow2-cluster.c | 16 +++++++++++----- > 1 file changed, 11 insertions(+), 5 deletions(-) >
Reviewed-by: Eric Blake <ebl...@redhat.com> -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature