pe: reject overflowing directory field RVAs #175
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/178"
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 ivall/xcl. Originally posted by BaggyALPHA on 2026-11-23T19:07:27Z.
PE 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
idxenreads from a CBV ignore the index – measured on Linux, Windows measurement wanted #304Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-23T20:50:27Z.
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.
Imported from ivall/xcl. Originally posted by ivall on 2026-11-23T21:09:11Z.
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).idxenreads from a CBV ignore the index – measured on Linux, Windows measurement wanted #304mainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #172mainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #172upstream-sync referenced this pull request2026-11-24 21:29:08 +00:00
upstream-sync referenced this pull request2026-11-25 11:09:41 +00:00
mainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #172