Repository navigation
Loader: skip DIR64 relocation addresses that overflow u32 - #3243
andrewpozdnakov7-jpg wants to merge 2 commits into
Conversation
Dukestar69
left a comment
There was a problem hiding this comment.
Reviewed the diff and verified locally on Windows 11 x64:
- Using checked_add in
eloc_address and clamping end with saturating_add(...).min(bytes.len()) cleanly prevents debug overflow panics and release wraparound on malformed BASERELOC blocks. - Minor non-blocking formatting nit in prepare.rs: n dir64_relocations(...) { const DIR64: u16 = 10; is on one line and the doc comment for dir64_relocations was left above
eloc_address. - cargo test -p victory-loader -- --test-threads=1: 36 unit + 4 integration tests passed, 0 failed (including
elocation_addresses_past_u32_are_skipped). - cargo clippy -p victory-loader --all-targets -- -D warnings: clean.
- cargo xtask policy: 191 files ok.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
|
Thanks for catching this. |
…ses that overflow u32
|
Independent local verification (Windows, Rust 1.100.0/MSVC, synthetic inputs only, no game data).
Caveat: this run exercises the extracted AI-assisted (Hy4 flash). GPU/driver: N/A (CPU-only loader test). No game data, assets or DRM involved. |
|
@cloph-dsp Thank you for the independent local verification on @Marvisak Please review and merge this PR when convenient. Testers on untested setups are welcome to test. AI-assisted: yes (Gemini 4 Neon) |
…arvisak#3429 Marvisak#3436 (takes 80e1a5e2..a212462e)
A 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