De-compress allows old-style LC_UNIXTHREAD with one LC_SEGMENT

https://github.com/upx/upx/issues/447
	modified:   p_mach.cpp
This commit is contained in:
John Reiser 2021-01-15 15:03:26 -08:00 committed by Markus F.X.J. Oberhumer
parent d86d5314ba
commit 5f98bb0ab0

View File

@ -1533,8 +1533,10 @@ int PackMachBase<T>::canUnpack()
my_cpusubtype = mhdri.cpusubtype; my_cpusubtype = mhdri.cpusubtype;
int headway = (int)mhdri.sizeofcmds; int headway = (int)mhdri.sizeofcmds;
if (headway < (int)(3 * sizeof(Mach_segment_command) // old style: LC_SEGMENT + LC_UNIXTHREAD [smaller, varies by $ARCH]
+ sizeof(Mach_main_command))) { // 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); infoWarning("Mach_header.sizeofcmds = %d too small", headway);
throwCantUnpack("file corrupted"); throwCantUnpack("file corrupted");
} }