[libvirt] [PATCH 02/12] storage: avoid mishandling backing store > 2GB
Eric Blake
eblake at redhat.com
Wed Jun 8 11:17:32 UTC 2011
On 06/07/2011 07:34 AM, Matthias Bolte wrote:
> 2011/6/6 Eric Blake <eblake at redhat.com>:
>> Detected by Coverity. The code was doing math on shifted unsigned
>> char (which promotes to int), then promoting that to unsigned long
>> during assignment to size. On 64-bit platforms, this risks sign
>> extending values of size > 2GiB. Bug present since commit
>> 489fd3 (v0.6.0).
>>
>> +#include <stdint.h>
>> #ifdef __linux__
>> # if HAVE_LINUX_MAGIC_H
>> # include <linux/magic.h>
>> @@ -274,7 +275,7 @@ qcowXGetBackingStore(char **res,
>> bool isQCow2)
>> {
>> unsigned long long offset;
>> - unsigned long size;
>> + uint32_t size;
>>
>> *res = NULL;
>> if (format)
>
> Using unsigned int instead of uint32_t would also work and avoid
> stdint.h types that the libvirt codebase avoids.
Sure, I'll push with that tweak.
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://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/libvir-list/attachments/20110608/e94d6483/attachment-0001.sig>
More information about the libvir-list
mailing list