1
0
mirror of https://github.com/upx/upx synced 2025-09-28 19:06:07 +08:00

Detect Mach_header.sizeofcmds==0

https://github.com/upx/upx/issues/448
	modified:   p_mach.cpp
This commit is contained in:
John Reiser 2021-01-17 17:09:35 -08:00 committed by Markus F.X.J. Oberhumer
parent c9fe84c9aa
commit 80de11bc5b

View File

@ -1811,8 +1811,9 @@ bool PackMachBase<T>::canPack()
char buf[32]; snprintf(buf, sizeof(buf), "bad sizeofcmds %d", sz_mhcmds);
throwCantPack(buf);
}
if (16384 < sz_mhcmds) { // somewhat arbitrary, but amd64-darwin.macho-upxmain.c
throwCantPack("16384 < Mach_header.sizeofcmds");
if (!sz_mhcmds
|| 16384 < sz_mhcmds) { // somewhat arbitrary, but amd64-darwin.macho-upxmain.c
throwCantPack("16384 < Mach_header.sizeofcmds (or ==0)");
}
rawmseg_buf.alloc(sz_mhcmds);
rawmseg = (Mach_segment_command *)(void *)rawmseg_buf;