From: John Ferlan Date: Thu, 4 Sep 2014 14:34:43 +0000 (-0400) Subject: storage: Resolve Coverity OVERFLOW_BEFORE_WIDEN X-Git-Tag: CVE-2014-3633~103 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f832aa32221d841360572d4279defa11a04efbcb;p=thirdparty%2Flibvirt.git storage: Resolve Coverity OVERFLOW_BEFORE_WIDEN 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 --- diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c index cb6a8d5469..abab1e19d6 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,