From b74e10e0660f5a1f7ca09345d89a933eb65fccdd Mon Sep 17 00:00:00 2001 From: Download-Fritz Date: Sun, 21 Oct 2018 11:58:21 +0200 Subject: [PATCH] OcMachoLib: Drop the "minimal LC size" check. It is implicitly covered by the checks below and worsens performance of valid binaries in favor of increasing it for invalid ones. --- Library/OcMachoLib/Header.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Library/OcMachoLib/Header.c b/Library/OcMachoLib/Header.c index 09bbd16f..4e56eb0e 100644 --- a/Library/OcMachoLib/Header.c +++ b/Library/OcMachoLib/Header.c @@ -51,7 +51,6 @@ MachoInitializeContext ( OUT VOID *Context ) { - UINTN MinCommandsSize; UINTN TopOfCommands; UINTN Index; CONST MACH_LOAD_COMMAND *Command; @@ -64,11 +63,9 @@ MachoInitializeContext ( // // Verify Mach-O Header sanity. // - TopOfCommands = ((UINTN)MachHeader->Commands + MachHeader->CommandsSize); - MinCommandsSize = (MachHeader->NumCommands * sizeof (*MachHeader->Commands)); + TopOfCommands = ((UINTN)MachHeader->Commands + MachHeader->CommandsSize); if ((FileSize < sizeof (*MachHeader)) || (MachHeader->Signature != MACH_HEADER_64_SIGNATURE) - || (MachHeader->CommandsSize < MinCommandsSize) || (TopOfCommands > ((UINTN)MachHeader + FileSize))) { return FALSE; }