Re: [PATCH 06/26] storage: Resolve Coverity OVERFLOW_BEFORE_WIDEN

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 09/05/14 00:26, John Ferlan wrote:
> Coverity complains that when multiplying to 32 bit values that eventually
> will be stored in a 64 bit value that it's possible the math could
> overflow unless one of the values being multiplied is type cast to
> the proper size.
> 
> Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
> ---
>  src/storage/storage_backend_disk.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c
> index cb6a8d5..abab1e1 100644
> --- a/src/storage/storage_backend_disk.c
> +++ b/src/storage/storage_backend_disk.c
> @@ -560,7 +560,7 @@ virStorageBackendDiskPartBoundaries(virStoragePoolObjPtr pool,
>      unsigned long long extraBytes = 0;
>      unsigned long long alignedAllocation = allocation;
>      virStoragePoolSourceDevicePtr dev = &pool->def->source.devices[0];
> -    unsigned long long cylinderSize = dev->geometry.heads *
> +    unsigned long long cylinderSize = (unsigned long long)dev->geometry.heads *
>                                        dev->geometry.sectors * SECTOR_SIZE;
>  
>      VIR_DEBUG("find free area: allocation %llu, cyl size %llu", allocation,
> 

ACK

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]