From d2e8118461ef82c975d9e1ce3855a2b9d44fa719 Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Fri, 26 Jul 2024 13:52:42 -0700 Subject: [PATCH] StandaloneMmPkg: CodeQL Fixes. Makes changes to comply with alerts raised by CodeQL. Most of the issues here fall into the following two categories: 1. Potential use of uninitialized pointer 2. Inconsistent integer width used in loop comparison Signed-off-by: Oliver Smith-Denny --- StandaloneMmPkg/Core/Dispatcher.c | 5 ++++- StandaloneMmPkg/Library/FvLib/FvLib.c | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/StandaloneMmPkg/Core/Dispatcher.c b/StandaloneMmPkg/Core/Dispatcher.c index b9fe3238465e..e55fdbabf2ca 100644 --- a/StandaloneMmPkg/Core/Dispatcher.c +++ b/StandaloneMmPkg/Core/Dispatcher.c @@ -655,7 +655,10 @@ FvIsBeingProcessed ( DEBUG ((DEBUG_INFO, "FvIsBeingProcessed - 0x%08x\n", FwVolHeader)); KnownFwVol = AllocatePool (sizeof (KNOWN_FWVOL)); - ASSERT (KnownFwVol != NULL); + if (KnownFwVol == NULL) { + ASSERT (FALSE); + return; + } KnownFwVol->Signature = KNOWN_FWVOL_SIGNATURE; KnownFwVol->FwVolHeader = FwVolHeader; diff --git a/StandaloneMmPkg/Library/FvLib/FvLib.c b/StandaloneMmPkg/Library/FvLib/FvLib.c index e0f344af3873..2faa7cd054f7 100644 --- a/StandaloneMmPkg/Library/FvLib/FvLib.c +++ b/StandaloneMmPkg/Library/FvLib/FvLib.c @@ -167,7 +167,7 @@ FfsFindNextFile ( FileOffset = (UINT32)((UINT8 *)FfsFileHeader - (UINT8 *)FwVolHeader); - while (FileOffset < (FvLength - sizeof (EFI_FFS_FILE_HEADER))) { + while ((UINT64)FileOffset < (FvLength - sizeof (EFI_FFS_FILE_HEADER))) { // // Get FileState which is the highest bit of the State //