[Libguestfs] [PATCH nbdkit] filters: cache, cow: Handle bitmap overflow on 32 bit architectures.
Eric Blake
eblake at redhat.com
Fri Jan 26 13:53:27 UTC 2018
On 01/26/2018 07:17 AM, Richard W.M. Jones wrote:
> When compiling on armv7 it becomes clear from the compiler warnings
> that the current code is wrong.
>
> The bitmap has to be allocated in virtual memory, so use size_t to
> describe the length of the bitmap. When changing the length of the
> bitmap, compute the new size as an unsigned 64 bit int, and then check
> whether or not it is too large to fit into size_t before casting it.
Indeed, size_t is a sane limit (the only way to get a larger map would
be using an mmap'd file on disk, so that we can use 64-bit off_t instead
of 32-bit size_t). We could also play games with having the granularity
get larger (doubling the size each bit represents lets you cache a
larger disk image). But erroring out for now, and leaving such
enhancements for a future contributor, is fine by me.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20180126/ad09d0fe/attachment.sig>
More information about the Libguestfs
mailing list