Fix #2412: reject out-of-range export addresses in parse_exports #3280

Open
github-bot wants to merge 3 commits from github-bot/gh-3280 into main AGit
Owner

@⁠tharun-37 on GitHub · 2026-11-26 15:39 UTC · original
tharun-37:fix/ghidra-export-validation → main · +41 −1 · 1 files · 3 commits · open

Fix #2412: Export address validation now uses checked_sub() instead of wrapping_sub(), preventing potential overflow when an export address is below image_base or exceeds u32::MAX.

Changes:

  • Addresses below image_base are now rejected with an error
  • Addresses exceeding u32::MAX are now rejected with an error
  • Valid RVAs pass through correctly

Added test accepts_export_address_at_u32_max verifying that an export address at u32::MAX is accepted.

**@⁠tharun-37** on GitHub · 2026-11-26 15:39 UTC · [original](https://github.com/Marvisak/VIctory/pull/3280) `tharun-37:fix/ghidra-export-validation` → `main` · +41 −1 · 1 files · 3 commits · open Fix #2412: Export address validation now uses checked_sub() instead of wrapping_sub(), preventing potential overflow when an export address is below image_base or exceeds u32::MAX. Changes: - Addresses below image_base are now rejected with an error - Addresses exceeding u32::MAX are now rejected with an error - Valid RVAs pass through correctly Added test accepts_export_address_at_u32_max verifying that an export address at u32::MAX is accepted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 15:42:15 +00:00
Author
Owner

@⁠AurumCarlos on GitHub · 2026-11-26 15:41 UTC · original · reviewed

Thanks for splitting it out, the diff is now just the parse_exports hunk. A few loose ends:

  • The description still mentions rejects_export_address_below_image_base, but this PR adds no test. Either drop that line, or add a test that really feeds an out-of-range address (the old one passed on the valid path, see my note on #3165).
  • As noted on #3165, object gives image_base + rva with a 32-bit RVA, so this can't trigger today. "Preventing integer overflow" would read better as a defensive check.
  • #3165 is still open with the same title and the other hunks; closing it (or retitling it for what's left) would avoid two PRs for #2412.
  • The new lines look longer than rustfmt allows; cargo fmt should reflow them.
**@⁠AurumCarlos** on GitHub · 2026-11-26 15:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/3280#pullrequestreview-6076937438) · **reviewed** Thanks for splitting it out, the diff is now just the `parse_exports` hunk. A few loose ends: - The description still mentions `rejects_export_address_below_image_base`, but this PR adds no test. Either drop that line, or add a test that really feeds an out-of-range address (the old one passed on the valid path, see my note on #3165). - As noted on #3165, `object` gives `image_base + rva` with a 32-bit RVA, so this can't trigger today. "Preventing integer overflow" would read better as a defensive check. - #3165 is still open with the same title and the other hunks; closing it (or retitling it for what's left) would avoid two PRs for #2412. - The new lines look longer than `rustfmt` allows; `cargo fmt` should reflow them.
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 16:11 UTC · original · approved these changes

Reviewed the diff and verified locally on Windows 11 x64:

  • Replacing address.wrapping_sub(image_base) as u32 with checked_sub(image_base) + u32::try_from cleanly rejects out-of-range export addresses with PeError::Malformed instead of silently truncating/wrapping.
  • cargo test -p victory-pe -- --test-threads=1: 36 passed, 0 failed.
  • cargo clippy -p victory-pe --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-26 16:11 UTC · [original](https://github.com/Marvisak/VIctory/pull/3280#pullrequestreview-6077316056) · **approved these changes** Reviewed the diff and verified locally on Windows 11 x64: - Replacing `address.wrapping_sub(image_base) as u32` with `checked_sub(image_base)` + `u32::try_from` cleanly rejects out-of-range export addresses with `PeError::Malformed` instead of silently truncating/wrapping. - `cargo test -p victory-pe -- --test-threads=1`: 36 passed, 0 failed. - `cargo clippy -p victory-pe --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3280/head:github-bot/gh-3280'
git switch 'github-bot/gh-3280'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3280'
git switch 'github-bot/gh-3280'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3280'
git switch 'github-bot/gh-3280'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3280'
git switch 'main'
git merge --squash 'github-bot/gh-3280'
git switch 'main'
git merge --ff-only 'github-bot/gh-3280'
git switch 'main'
git merge 'github-bot/gh-3280'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!3280
No description provided.