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

At ::unpack much of decompressed Mach_header must match outer Mach_header

This commit is contained in:
John Reiser 2015-05-09 20:14:32 -07:00
parent cdd152d015
commit cb35ba4543
2 changed files with 7 additions and 2 deletions

View File

@ -1304,6 +1304,11 @@ void PackMachBase<T>::unpack(OutputFile *fo)
fi->readx(ibuf, ph.c_len);
Mach_header *const mhdr = (Mach_header *)new upx_byte[ph.u_len];
decompress(ibuf, (upx_byte *)mhdr, false);
if (mhdri.magic != mhdr->magic
|| mhdri.cputype != mhdr->cputype
|| mhdri.cpusubtype != mhdr->cpusubtype
|| mhdri.filetype != mhdr->filetype)
throwCantUnpack("file header corrupted");
unsigned const ncmds = mhdr->ncmds;
msegcmd = new Mach_segment_command[ncmds];

View File

@ -71,7 +71,7 @@ __packed_struct(Mach_header)
Word magic;
Word cputype;
Word cpysubtype;
Word cpusubtype;
Word filetype;
Word ncmds;
Word sizeofcmds;
@ -87,7 +87,7 @@ __packed_struct(Mach_header64)
Word magic;
Word cputype;
Word cpysubtype;
Word cpusubtype;
Word filetype;
Word ncmds;
Word sizeofcmds;