Loader: skip DIR64 relocation addresses that overflow u32 #3243
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!3243
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3243"
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?
@andrewpozdnakov7-jpg on GitHub · 2026-11-26 14:22 UTC · original
andrewpozdnakov7-jpg:fix/2411-dir64-page-overflow→main· +30 −3 · 1 files · 2 commits · openA malformed
BASERELOCblock puts the page RVA nearu32::MAX;page + u32::from(e & 0xFFF)indir64_relocationsthen panics in debug builds and wraps in release ones, returning a relocation address that was never in the image.reloc_addressnow useschecked_add, and an entry that does not fit is skipped on its own, so a bad page base does not throw away the well-formed entries after it.endis clamped tobytes.len()withsaturating_add; valid files are unchanged, since the directory is inside the file.relocation_addresses_past_u32_are_skippedcovers0x1000 + 0x0A, the last address0xFFFF_FFF0 + 0xF, the overflowing0xFFFF_FFF0 + 0x10, and the type/offset split0xA000 -> 0x2000.cargo test -p victory-loader: 35 passed, 1 failed. The failure isprepare::tests::windows_assigns_static_tls_to_a_prepared_dll("the test binary uses static TLS"); it fails identically with this patch stashed, so it is local to this machine.cargo clippy -p victory-loader --all-targets -- -D warnings: clean.cargo xtask policy: 192 files ok.The other two points in #2411 cannot fail on the 64-bit hosts VIctory builds for:
start + sizeandat + blockare ausizeplus au32, and reads past the end already stop throughlayout::read_u32andbytes.get. #2418 guards those as well, with aproposed closetriage for that reason; thereloc_addresschange is the behavioural difference. The issue's proposed arithmetic came from @pushkarreddyy.Fixes #2411.
Coordination
@Dukestar69 on GitHub · 2026-11-26 14:30 UTC · original · approved these changes
Reviewed the diff and verified locally on Windows 11 x64:
eloc_address and clamping end with saturating_add(...).min(bytes.len()) cleanly prevents debug overflow panics and release wraparound on malformed BASERELOC blocks.
eloc_address.
elocation_addresses_past_u32_are_skipped).
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@andrewpozdnakov7-jpg on GitHub · 2026-11-26 15:39 UTC · original
Thanks for catching this.
2b898b6moves the iterator's doc comment back todir64_relocationsand putsconst DIR64on its own line. The patch changes comments and whitespace. The loader builds with all features.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.