From: Ranbir Singh <ranbir.sin...@dell.com> The function FatInitializeDiskCache evaluates an expression
FAT_DATACACHE_GROUP_COUNT << DiskCache[CacheData].PageAlignment and assigns it to DataCacheSize which is of type UINTN. As per Coverity report, FAT_DATACACHE_GROUP_COUNT << DiskCache[CacheData].PageAlignment is a potentially overflowing expression with type "int" (32 bits, signed) evaluated using 32-bit arithmetic, and then used in a context that expects an expression of type "UINTN" (64 bits, unsigned). To avoid overflow, cast "FAT_DATACACHE_GROUP_COUNT" to type "UINTN". REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4249 Cc: Ray Ni <ray...@intel.com> Co-authored-by: Veeresh Sangolli <veeresh.sango...@dellteam.com> Signed-off-by: Ranbir Singh <ranbir.sin...@dell.com> Signed-off-by: Ranbir Singh <rsi...@ventanamicro.com> --- FatPkg/EnhancedFatDxe/DiskCache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FatPkg/EnhancedFatDxe/DiskCache.c b/FatPkg/EnhancedFatDxe/DiskCache.c index d1a34a6a646f..d56e338586d8 100644 --- a/FatPkg/EnhancedFatDxe/DiskCache.c +++ b/FatPkg/EnhancedFatDxe/DiskCache.c @@ -477,7 +477,7 @@ FatInitializeDiskCache ( DiskCache[CacheFat].BaseAddress = Volume->FatPos; DiskCache[CacheFat].LimitAddress = Volume->FatPos + Volume->FatSize; FatCacheSize = FatCacheGroupCount << DiskCache[CacheFat].PageAlignment; - DataCacheSize = FAT_DATACACHE_GROUP_COUNT << DiskCache[CacheData].PageAlignment; + DataCacheSize = (UINTN)FAT_DATACACHE_GROUP_COUNT << DiskCache[CacheData].PageAlignment; // // Allocate the Fat Cache buffer // -- 2.34.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#109140): https://edk2.groups.io/g/devel/message/109140 Mute This Topic: https://groups.io/mt/101633789/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-