pe: reject overflowing directory field RVAs #178
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!178
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/178/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?
@BaggyALPHA on GitHub · 2026-11-23 19:07 UTC · original
BaggyALPHA:fix/pe-directory-rva-overflow→main· +125 −13 · 1 files · 1 commits · merged 2026-11-23 21:08 UTCPE directory bases are checked, but additions for individual fields can still overflow after the first field is successfully read. Small malformed PE files with a section near the u32 RVA limit trigger panics in debug builds; optimized builds can wrap into the image headers and accept malformed data.
Use checked RVA additions for import/delay-import descriptor fields, relocation block headers/entries, and TLS directory fields, returning
PeError::BadRva. Add six tests covering 14 overflow boundary cases and controls at ordinary and high non-overflowing RVAs. All fixtures are generated in the tests; no external data is needed.Related to #106 (malformed-PE parsing).
Validation
Base:
956a476bf738a098f39df4f4c8acef682e43030f. Windows x64, Rust 1.96.0, RTX 3080.cargo test --locked -p xcl --lib pe::tests -- --nocapturerustc --edition 2024 --test -O crates/xcl/src/pe.rs)cargo build --locked --workspacecargo test --locked -p xcl --test e2e -- --nocapture --test-threads=1git diff --checkThe baseline binaries used the original production code plus the updated test module. This is parser robustness coverage, not evidence of improved retail-title compatibility. Console/retail fixtures remain unavailable; those tests and the full workspace test suite were not run. The synthetic title and game DLL were built from the workspace before the end-to-end tests.
Personal filesystem paths have been removed from the logs below. The PR diff contains the complete fix and fixtures.
Parser reproduction, unit tests, and build output
Synthetic-title end-to-end output
@Kalmarv on GitHub · 2026-11-23 20:50 UTC · original
Linux / Wine / GNU run of
5911fb07(merge-base956a476, the currentmain). Ubuntu 24.04, XCL cross-built forx86_64-pc-windows-gnu(mingw-w64 13, release, so no overflow checks), run under Wine 11.21 Staging (Kron4ek wow64 build). The control is this PR's head with only the production hunks reverse-applied, so the new tests stay in.pe::tests(10 tests):pe.rsreverted)delay_import_descriptor_field_rva_overflow_is_error(offset 8),relocation_entry_rva_overflow_is_error,tls_field_rva_overflow_is_error(offset 8)This is the same 7/3 split as your optimized Windows baseline: in an optimized build the additions wrap and the malformed data is accepted, rather than panicking. So the GNU toolchain agrees with MSVC here. No findings from reading the diff.
Not covered: a debug build (overflow panics); fuzzing beyond the 14 boundaries; any title.
@ivall on GitHub · 2026-11-23 21:09 UTC · original
Merged (main
6da33fa). Checked on an RX 9070 (RDNA4) with the 22 PRs merged together on maineaa36b6:cargo build --workspace && cargo test --workspace -- --test-threads=4- 582 unit tests passed, 0 failed (20 ignored), the integration and e2e tests passed too; and the retail game still reaches its first menu (646 frames in 30 s, no device removal).