mirror of https://github.com/acidanthera/audk.git
MdePkg: Fix overflow issue in BasePeCoffLib
The RelocDir->Size is a UINT32 value, and RelocDir->VirtualAddress is also a UINT32 value. The current code does not check for overflow when adding RelocDir->Size to RelocDir->VirtualAddress. This patch adds a check to ensure that the addition does not overflow. Signed-off-by: Doug Flick <dougflick@microsoft.com> Authored-by: sriraamx gobichettipalayam <sri..@intel.com>
This commit is contained in:
parent
517019a553
commit
c95233b852
|
@ -1054,7 +1054,7 @@ PeCoffLoaderRelocateImage (
|
|||
RelocDir = &Hdr.Te->DataDirectory[0];
|
||||
}
|
||||
|
||||
if ((RelocDir != NULL) && (RelocDir->Size > 0)) {
|
||||
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,
|
||||
|
|
Loading…
Reference in New Issue