pe: reject RVA mappings outside the file #26
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/26"
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?
Imported from omonkeyz/xbox-emulator. Originally posted by zerkend on 2026-11-21T18:06:58Z.
Library / 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
Imported from omonkeyz/xbox-emulator. Originally posted by omonkeyz on 2026-11-22T13:13:15Z.
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