PE: reject out-of-range export addresses in parse_exports instead of wrapping #2410
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 Marvisak/VIctory. Originally posted by pushkarreddyy on 2026-11-25T13:07:30Z.
Summary
In
crates/victory-pe/src/image.rs(parse_exports), export RVAs are reconstructed fromobject'sReadTarget::Address { address }using:If a malformed PE export address is below
image_baseoraddress - image_base > u32::MAX,wrapping_sub+as u32silently wraps/truncates into a bogus 32-bit RVA instead of returningPeError::Malformed.Expected
Use
checked_sub(image_base)andu32::try_from, returningPeError::Malformedon out-of-range export addresses.Claiming this issue and opening a PR with unit tests shortly.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T15:45:57Z.
Automated triage for the maintainers.
Read against main (
da82e44): incrates/victory-pe/src/image.rs,parse_exports, the addressobject(0.41) hands back is the image base plus the 32-bit RVA stored in the export address table.address.wrapping_sub(image_base) as u32undoes exactly that sum, so it always recovers the original table value; an export address below the image base or more thanu32::MAXpast it cannot arise from a PE file. What the table holds can still point outside the image, butchecked_sub/try_fromwould not detect that; it would need a check against the image size. PR #2420 (open) makes the change described here.Generated by Claude Code