mirror of
https://github.com/acidanthera/audk.git
synced 2025-09-25 02:37:39 +02:00
MdePkg/BasePeCoffLib2: Only validate ExeHdrOffset when non-zero
This commit is contained in:
parent
42ef8c795c
commit
7b022c46d0
@ -840,6 +840,13 @@ PeCoffInitializeContext (
|
||||
}
|
||||
|
||||
Context->ExeHdrOffset = DosHdr->e_lfanew;
|
||||
//
|
||||
// Verify the Execution Header offset is sufficiently aligned.
|
||||
//
|
||||
if (!PcdGetBool (PcdImageLoaderAllowMisalignedOffset)
|
||||
&& !IS_ALIGNED (Context->ExeHdrOffset, ALIGNOF (EFI_IMAGE_NT_HEADERS_COMMON_HDR))) {
|
||||
return RETURN_UNSUPPORTED;
|
||||
}
|
||||
} else if (!PcdGetBool (PcdImageLoaderProhibitTe)) {
|
||||
//
|
||||
// Assume the Image starts with the Executable Header, determine whether it
|
||||
@ -865,13 +872,6 @@ PeCoffInitializeContext (
|
||||
if (FileSize - Context->ExeHdrOffset < sizeof (EFI_IMAGE_NT_HEADERS_COMMON_HDR) + sizeof (UINT16)) {
|
||||
return RETURN_UNSUPPORTED;
|
||||
}
|
||||
//
|
||||
// Verify the Execution Header offset is sufficiently aligned.
|
||||
//
|
||||
if (!PcdGetBool (PcdImageLoaderAllowMisalignedOffset)
|
||||
&& !IS_ALIGNED (Context->ExeHdrOffset, ALIGNOF (EFI_IMAGE_NT_HEADERS_COMMON_HDR))) {
|
||||
return RETURN_UNSUPPORTED;
|
||||
}
|
||||
|
||||
STATIC_ASSERT (
|
||||
ALIGNOF (UINT32) <= ALIGNOF (EFI_IMAGE_NT_HEADERS_COMMON_HDR),
|
||||
|
Loading…
x
Reference in New Issue
Block a user