pe: reject RVA mappings outside the file #26
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
library
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/omonkeyz--xbox-emulator!26
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/26/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@zerkend on GitHub · 2026-11-21 18:06 UTC · original
zerkend:codex/pe-rva-validation→main· +86 −2 · 2 files · 63 commits · closed without mergingLibrary / area: tombox-pe
Exports changed: none
PeFile::rva_to_offsetcould returnOkwith a file offset at or beyond EOF. A synthetic 512-byte PE reproduced both a section mapping to 4294967040 and a header mapping to 768. Malformed section ranges remain inspectable through the parser's notes, but their nonexistent bytes must not map successfully.Check section offset addition and require the resulting byte to exist. Apply the same EOF check to the header fallback. Keep valid bytes in partially truncated sections mappable, and preserve rejection of virtual-only/BSS bytes.
Source of behaviour: the method's documented file-backed mapping contract and the existing bounds-checked Reader API; fixtures are hand-built PE32+ headers.
Validation (Windows, Rust 1.100):
cargo test --locked -p tombox-pe: 13 passed.The new cases fail against the original implementation (3 failed, 1 passed), then all 4 pass with the fix.
git diff --checkpasses.No game/console files or binaries included
@omonkeyz on GitHub · 2026-11-22 13:13 UTC · original
Main's history was rewritten, which auto-closed this PR (sorry for the noise). Superseded: rva_to_offset on main already has the same checked bound.
Pull request closed