PE loader: skip export ordinals that overflow u32::MAX (#691) #727
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!727
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/727/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?
@faizanzatro on GitHub · 2026-11-24 04:09 UTC · original
faizanzatro:fix/pe-export-ordinal-overflow→main· +22 −1 · 1 files · 1 commits · closed without mergingFixes #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
@faizanzatro on GitHub · 2026-11-24 04:14 UTC · original
Closing in favor of earlier draft PR #700 by @towiice.
@lordon1a on GitHub · 2026-11-24 04:15 UTC · original
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