Skip to content

Commit

Permalink
MdePkg: Improving readability of CVE patch for PeCoffLoaderRelocateImage
Browse files Browse the repository at this point in the history
This change adds parantheses to the if condition detecting overflow in
the PeCoffLoaderRelocateImage function to improve readability.

Follow on change for:
    REF!: #6249

Signed-off-by: Doug Flick <[email protected]>
  • Loading branch information
Flickdm committed Oct 2, 2024
1 parent cac73c4 commit 7eb5a9e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion MdePkg/Library/BasePeCoffLib/BasePeCoff.c
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,7 @@ PeCoffLoaderRelocateImage (
RelocDir = &Hdr.Te->DataDirectory[0];
}

if ((RelocDir != NULL) && (RelocDir->Size > 0) && (RelocDir->Size - 1 < MAX_UINT32 - RelocDir->VirtualAddress)) {
if ((RelocDir != NULL) && (RelocDir->Size > 0) && ((RelocDir->Size - 1) < (MAX_UINT32 - RelocDir->VirtualAddress))) {
RelocBase = (EFI_IMAGE_BASE_RELOCATION *)PeCoffLoaderImageAddress (ImageContext, RelocDir->VirtualAddress, TeStrippedOffset);
RelocBaseEnd = (EFI_IMAGE_BASE_RELOCATION *)PeCoffLoaderImageAddress (
ImageContext,
Expand Down

0 comments on commit 7eb5a9e

Please sign in to comment.