From: Ranbir Singh <[email protected]>
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 <[email protected]>
Co-authored-by: Veeresh Sangolli <[email protected]>
Signed-off-by: Ranbir Singh <[email protected]>
Signed-off-by: Ranbir Singh <[email protected]>
---
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 (#110818): https://edk2.groups.io/g/devel/message/110818
Mute This Topic: https://groups.io/mt/102438365/21656
Group Owner: [email protected]
Unsubscribe: https://edk2.groups.io/g/devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-