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
+5
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];