Detect sizeofcmds too small

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=66330&q=label%3AProj-upx
	modified:   p_mach.cpp
This commit is contained in:
John Reiser 2024-05-04 10:10:37 -07:00
parent 548227a55b
commit 2ea316d754

View File

@ -1645,7 +1645,8 @@ tribool PackMachBase<T>::canUnpack()
unsigned const ncmds = mhdri.ncmds;
int headway = (int)mhdri.sizeofcmds;
if (!ncmds || MAX_N_CMDS < ncmds || file_size < headway) {
if (!ncmds || MAX_N_CMDS < ncmds || file_size < headway
|| headway < 4*4 ) {
char msg[80]; snprintf(msg, sizeof(msg),
"bad Mach_header ncmds=%d sizeofcmds=0x%x", ncmds, headway);
throwCantUnpack(msg);