PE loader: skip export ordinals that overflow u32::MAX (#691) #722
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/727"
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 faizanzatro on 2026-11-24T04:09:06Z.
Fixes #691.
What is in it
OwnedExports::from_peincrates/xcl/src/pe.rspreviously addedex.ordinal_baseto the function loop indexi as u32using unchecked arithmetic. When parsing a crafted or malformed PE image whereordinal_baseis close tou32::MAX, this caused an integer overflow panic in debug builds and wrapped around to shadow low ordinals (such as ordinal 0) in release builds.This fix:
ex.ordinal_base.checked_add(i as u32)when inserting intoout.by_ordinal.u32::MAX(entries pastu32::MAXcannot be valid 32-bit ordinals).export_ordinals_past_u32_max_are_skippedverifying that ordinals atu32::MAXare preserved while overflowing ones are skipped without panicking or wrapping.Tested
cargo test -p xcl --lib pe::: 11 passed, 0 failedcargo test --workspace -- --test-threads=4: 682 passed, 0 failed, 41 ignored (2 GPU tests skipped: no wave64).\scripts\test.ps1: all workspace builds and tests pass cleanlyNot tested
AI use
Imported from ivall/xcl. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-24T04:09:21Z.
Review: COMMENTED
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
Imported from ivall/xcl. Originally posted by faizanzatro on 2026-11-24T04:14:31Z.
Closing in favor of earlier draft PR #700 by @towiice.
Imported from ivall/xcl. Originally posted by lordon1a on 2026-11-24T04:15:45Z.
Independent test report on
da7a9bd:Tested
616.64, wave32, SM 6.6), Intel i7-12700H, Windows 11 Home 26H2 (build 26200),rustc 1.100.0(x86_64-pc-windows-gnullvm), debug build, DXC1.9.2609.5(01b62ad4)cargo test -p xcl --lib pe::tests -- --nocapture0.06s(export_ordinals_past_u32_max_are_skippedok)Not tested
xcl-smoke)AI use
da7a9bdin a detached worktree, audited the diff, ran the test suite, and posted this report.Pull request closed