At ::unpack much of decompressed Mach_header must match outer Mach_header
This commit is contained in:
@@ -1304,6 +1304,11 @@ void PackMachBase<T>::unpack(OutputFile *fo)
|
|||||||
fi->readx(ibuf, ph.c_len);
|
fi->readx(ibuf, ph.c_len);
|
||||||
Mach_header *const mhdr = (Mach_header *)new upx_byte[ph.u_len];
|
Mach_header *const mhdr = (Mach_header *)new upx_byte[ph.u_len];
|
||||||
decompress(ibuf, (upx_byte *)mhdr, false);
|
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;
|
unsigned const ncmds = mhdr->ncmds;
|
||||||
|
|
||||||
msegcmd = new Mach_segment_command[ncmds];
|
msegcmd = new Mach_segment_command[ncmds];
|
||||||
|
|||||||
+2
-2
@@ -71,7 +71,7 @@ __packed_struct(Mach_header)
|
|||||||
|
|
||||||
Word magic;
|
Word magic;
|
||||||
Word cputype;
|
Word cputype;
|
||||||
Word cpysubtype;
|
Word cpusubtype;
|
||||||
Word filetype;
|
Word filetype;
|
||||||
Word ncmds;
|
Word ncmds;
|
||||||
Word sizeofcmds;
|
Word sizeofcmds;
|
||||||
@@ -87,7 +87,7 @@ __packed_struct(Mach_header64)
|
|||||||
|
|
||||||
Word magic;
|
Word magic;
|
||||||
Word cputype;
|
Word cputype;
|
||||||
Word cpysubtype;
|
Word cpusubtype;
|
||||||
Word filetype;
|
Word filetype;
|
||||||
Word ncmds;
|
Word ncmds;
|
||||||
Word sizeofcmds;
|
Word sizeofcmds;
|
||||||
|
|||||||
Reference in New Issue
Block a user