From: Ranbir.Singh3@Dell.com
To: devel@edk2.groups.io
Subject: FatPkg: Fix EnhancedFatDxe driver coverity issues
Date: Thu, 22 Dec 2022 02:02:29 -0800 [thread overview]
Message-ID: <5nHJ.1671703349525859193.DxyM@groups.io> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 171 bytes --]
Hi All,
Attached patch contains the changes fixing the issues pointed by Coverity scan on FatPkg component.
Please review if the changes are safe to be considered.
[-- Attachment #1.2: Type: text/html, Size: 187 bytes --]
[-- Attachment #2: 0001-FatPkg-Fix-EnhancedFatDxe-driver-coverity-issues.patch --]
[-- Type: text/plain, Size: 2490 bytes --]
From 2be2f147b1193a15b6aac7e231c67ff318fcb9ee Mon Sep 17 00:00:00 2001
From: Ranbir Singh <Ranbir.Singh3@Dell.com>
Date: Wed, 21 Dec 2022 16:53:29 +0530
Subject: [PATCH] FatPkg: Fix EnhancedFatDxe driver coverity issues
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4199
Use proper typecast to avoid SIGN_EXTENSION and OVERFLOW_BEFORE_WIDEN.
Signed-off-by: Ranbir Singh <Ranbir.Singh3@Dell.com>
---
FatPkg/EnhancedFatDxe/DirectoryManage.c | 4 ++--
FatPkg/EnhancedFatDxe/DiskCache.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/FatPkg/EnhancedFatDxe/DirectoryManage.c b/FatPkg/EnhancedFatDxe/DirectoryManage.c
index 723fc35f38..cc4acfec2f 100644
--- a/FatPkg/EnhancedFatDxe/DirectoryManage.c
+++ b/FatPkg/EnhancedFatDxe/DirectoryManage.c
@@ -474,7 +474,7 @@ FatGetDirEntInfo (
Info = Buffer;
Info->Size = ResultSize;
if ((Entry->Attributes & FAT_ATTRIBUTE_DIRECTORY) != 0) {
- Cluster = (Entry->FileClusterHigh << 16) | Entry->FileCluster;
+ Cluster = ((UINTN)(Entry->FileClusterHigh) << 16) | (UINTN)Entry->FileCluster;
Info->PhysicalSize = FatPhysicalDirSize (Volume, Cluster);
Info->FileSize = Info->PhysicalSize;
} else {
@@ -1167,7 +1167,7 @@ FatOpenDirEnt (
//
Volume = Parent->Volume;
OFile->FullPathLen = Parent->FullPathLen + 1 + StrLen (DirEnt->FileString);
- OFile->FileCluster = ((DirEnt->Entry.FileClusterHigh) << 16) | (DirEnt->Entry.FileCluster);
+ OFile->FileCluster = (((UINTN)(DirEnt->Entry.FileClusterHigh)) << 16) | (DirEnt->Entry.FileCluster);
InsertTailList (&Parent->ChildHead, &OFile->ChildLink);
} else {
//
diff --git a/FatPkg/EnhancedFatDxe/DiskCache.c b/FatPkg/EnhancedFatDxe/DiskCache.c
index d1a34a6a64..d56e338586 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.36.1.windows.1
reply other threads:[~2022-12-22 10:02 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5nHJ.1671703349525859193.DxyM@groups.io \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox