Detect LC_SEGMENT beyond end-of-file in PackMachBase<T>::find_SEGMENT_gap.

This commit is contained in:
John Reiser 2010-04-28 20:05:23 -07:00
parent e56799c993
commit 99a208110b

View File

@ -861,6 +861,8 @@ unsigned PackMachBase<T>::find_SEGMENT_gap(
}
unsigned const hi = msegcmd[k].fileoff + msegcmd[k].filesize;
unsigned lo = ph.u_file_size;
if (lo < hi)
throwCantPack("bad input: LC_SEGMENT beyond end-of-file");
unsigned j = k;
for (;;) { // circular search, optimize for adjacent ascending
++j;