initial headway is limited by both file_size and mhcmdi.sizeofcmds
https://github.com/upx/upx/issues/732 modified: p_mach.cpp
This commit is contained in:
parent
e79c790264
commit
ae77fd60bb
@ -1952,7 +1952,7 @@ tribool PackMachBase<T>::canPack()
|
|||||||
throwCantPack("256 < Mach_header.ncmds");
|
throwCantPack("256 < Mach_header.ncmds");
|
||||||
}
|
}
|
||||||
unsigned const sz_mhcmds = (unsigned)mhdri.sizeofcmds;
|
unsigned const sz_mhcmds = (unsigned)mhdri.sizeofcmds;
|
||||||
unsigned headway = file_size - sizeof(mhdri);
|
unsigned headway = umin(sz_mhcmds, file_size - sizeof(mhdri));
|
||||||
if (headway < sz_mhcmds) {
|
if (headway < sz_mhcmds) {
|
||||||
char buf[32]; snprintf(buf, sizeof(buf), "bad sizeofcmds %d", sz_mhcmds);
|
char buf[32]; snprintf(buf, sizeof(buf), "bad sizeofcmds %d", sz_mhcmds);
|
||||||
throwCantPack(buf);
|
throwCantPack(buf);
|
||||||
@ -1961,7 +1961,7 @@ tribool PackMachBase<T>::canPack()
|
|||||||
|| 32768 < sz_mhcmds) { // somewhat arbitrary, but *-darwin.macho-upxmain.c
|
|| 32768 < sz_mhcmds) { // somewhat arbitrary, but *-darwin.macho-upxmain.c
|
||||||
throwCantPack("32768 < Mach_header.sizeofcmds (or ==0)");
|
throwCantPack("32768 < Mach_header.sizeofcmds (or ==0)");
|
||||||
}
|
}
|
||||||
rawmseg_buf.alloc(sz_mhcmds);
|
rawmseg_buf.alloc(headway);
|
||||||
rawmseg = (Mach_segment_command *)(void *)rawmseg_buf;
|
rawmseg = (Mach_segment_command *)(void *)rawmseg_buf;
|
||||||
fi->readx(rawmseg, mhdri.sizeofcmds);
|
fi->readx(rawmseg, mhdri.sizeofcmds);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user