[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [PATCH 2/2] qcow2: Fix qcow2_get_cluster_offset()
From: |
Eric Blake |
Subject: |
Re: [Qemu-block] [PATCH 2/2] qcow2: Fix qcow2_get_cluster_offset() |
Date: |
Mon, 20 Jun 2016 09:31:58 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 |
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 <address@hidden>
> ---
> block/qcow2-cluster.c | 16 +++++++++++-----
> 1 file changed, 11 insertions(+), 5 deletions(-)
>
Reviewed-by: Eric Blake <address@hidden>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature