mirror of
https://github.com/acidanthera/audk.git
synced 2025-09-25 18:48:42 +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;
|
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)) {
|
} else if (!PcdGetBool (PcdImageLoaderProhibitTe)) {
|
||||||
//
|
//
|
||||||
// Assume the Image starts with the Executable Header, determine whether it
|
// 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)) {
|
if (FileSize - Context->ExeHdrOffset < sizeof (EFI_IMAGE_NT_HEADERS_COMMON_HDR) + sizeof (UINT16)) {
|
||||||
return RETURN_UNSUPPORTED;
|
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 (
|
STATIC_ASSERT (
|
||||||
ALIGNOF (UINT32) <= ALIGNOF (EFI_IMAGE_NT_HEADERS_COMMON_HDR),
|
ALIGNOF (UINT32) <= ALIGNOF (EFI_IMAGE_NT_HEADERS_COMMON_HDR),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user