On Mon 13 May 2019 01:28:46 PM CEST, Stefano Garzarella wrote:
>> +            int size = QCOW2_COMPRESSED_SECTOR_SIZE *
>> +                (((l2_entry >> s->csize_shift) & s->csize_mask) + 1);
>
> What about using int64_t type for the 'size' variable?
> (because the qcow2_free_clusters() 'size' parameter is int64_t)

The maximum size that can be read from a compressed cluster descriptor
using the formula above is twice the cluster size (more information on
commit abd3622cc03cf41ed542126a540385f30a4c0175 and on the Compressed
Clusters Descriptor spec in docs/interop/qcow2.txt).

Since the maximum allowed cluster size is 2MB, the value of the 'size'
variable can never be larger than 4MB, which fits comfortably on a
32-bit integer. We would need to support 512MB clusters in order to have
problems with this.

Berto

Reply via email to