From 5f98bb0ab0ae865a0d1c69fd6c569f5f62458433 Mon Sep 17 00:00:00 2001 From: John Reiser Date: Fri, 15 Jan 2021 15:03:26 -0800 Subject: [PATCH] De-compress allows old-style LC_UNIXTHREAD with one LC_SEGMENT https://github.com/upx/upx/issues/447 modified: p_mach.cpp --- src/p_mach.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/p_mach.cpp b/src/p_mach.cpp index 52848c22..131cc45c 100644 --- a/src/p_mach.cpp +++ b/src/p_mach.cpp @@ -1533,8 +1533,10 @@ int PackMachBase::canUnpack() my_cpusubtype = mhdri.cpusubtype; int headway = (int)mhdri.sizeofcmds; - if (headway < (int)(3 * sizeof(Mach_segment_command) - + sizeof(Mach_main_command))) { + // old style: LC_SEGMENT + LC_UNIXTHREAD [smaller, varies by $ARCH] + // new style: 3*LC_SEGMENT + LC_MAIN [larger] + // FIXME: So this test is weak. + if (headway < (int)(sizeof(Mach_segment_command) + 4*4)) { infoWarning("Mach_header.sizeofcmds = %d too small", headway); throwCantUnpack("file corrupted"); }