Commit 16a0342
Improve bounds checking and add file-backed validation in MachoView
Replace ad-hoc modulo guards with principled bounds derived from file
structure where possible. The indirect symbol count is now clamped to
the number of entries that physically fit between the table offset and
end of file, accounting for the universal (fat) binary slice offset,
using the OS-reported file size rather than any field from the binary.
Export trie traversal uses the buffer length as its node visit limit,
which prevents unbounded traversal including cyclic tries. Rebase and
bind opcode entry counts are bounded by a single per-table total derived
from the size of the Mach-O slice divided by its pointer size, scaled by
a configurable multiplier (loader.macho.maxRebaseBindEntriesMultiplier,
default 1.0), shared across all opcodes in one table via emitRebase/
emitBind helpers so every opcode that records an entry consumes the same
budget. The endGuard underflow when the export trie buffer is empty, the
symbols_offset wraparound in ProcessImports, and a missing catch(...)
in MachoView::Init are also fixed.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 7c29ccd commit 16a0342
3 files changed
Lines changed: 152 additions & 115 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
313 | 313 | | |
314 | 314 | | |
315 | 315 | | |
316 | | - | |
317 | | - | |
| 316 | + | |
318 | 317 | | |
319 | | - | |
| 318 | + | |
320 | 319 | | |
321 | 320 | | |
322 | 321 | | |
| |||
0 commit comments