Check Mach_header.ncmds at unpack
https://github.com/upx/upx/issues/563 modified: p_mach.cpp
This commit is contained in:
parent
660aee6d22
commit
651155c64d
@ -1508,6 +1508,11 @@ void PackMachBase<T>::unpack(OutputFile *fo)
|
||||
throwCantUnpack("file header corrupted");
|
||||
unsigned const ncmds = mhdr->ncmds;
|
||||
|
||||
if (!ncmds || 24 < ncmds) { // arbitrary limit
|
||||
char msg[40]; snprintf(msg, sizeof(msg),
|
||||
"bad Mach_header.ncmds = %d", ncmds);
|
||||
throwCantUnpack(msg);
|
||||
}
|
||||
msegcmd_buf.alloc(sizeof(Mach_segment_command) * ncmds);
|
||||
msegcmd = (Mach_segment_command *)msegcmd_buf.getVoidPtr();
|
||||
unsigned char const *ptr = (unsigned char const *)(1+mhdr);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user