Loader: fix 4 bounds and cleanup bugs in windows.rs with unit tests #1047
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 geiyiliyabumo on 2026-11-24T15:16:17Z.
Summary
Fixes 4 real bounds-checking and cleanup bugs in
crates/victory-loader/src/windows.rs(previously 0 unit tests) and adds 13 deterministic synthetic unit tests.Because external PR creation is currently restricted (
collaborators_only), the CI-green branch is ready on my fork for cherry-pick / review:geiyiliyabumo/VIctory@test/loader-windowsgeiyiliyabumo/VIctory@98b761b(based onmainffe310e)Bugs Fixed (
crates/victory-loader/src/windows.rs)write_slotsnow validatesrva + 8 <= size_of_imageas a batch before any write.loadnow callsFreeLibrarywhentls::redirectfails afterLoadLibraryExW.0or>= size_of_imageare now logged and skipped instead of executed.DllMain/ entry point: guarded in bothnotifyandspawn_main.Verification (Windows 11 x64 MSVC)
rustfmt --edition 2024 --check crates/victory-loader/src/windows.rs: PASScargo xtask policy: PASS (154 files ok)cargo clippy -p victory-loader --all-targets --locked -- -D warnings(default +--features diagnostics): PASS (0 warnings)cargo test -p victory-loader --locked -- windows::: 13 passed, 0 failedAI-assisted; synthetic tests only, no game files.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T06:52:13Z.
Automated triage for the maintainers.
Correction to the earlier note: the TLS-redirect part of this is open as PR #1201 ("free mapped module on TLS redirect error and add windows.rs unit tests"), which links this issue.
One of the four cases holds on current
main(940d32f). Inload(crates/victory-loader/src/windows.rs), an error fromtls::redirectreturns through?afterLoadLibraryExWmapped the image.LoadedImagehas noDrop, andFreeLibraryis called only inunload, so the module stays mapped. The impact is small, because that error ends the run anyway. #1201 fixes it.The other three cases (IAT slots in
write_slots, out-of-image TLS callbacks, out-of-image entry points) still read as hardening.write_slotsrelies on the parser yielding only slots inside the image, and nothing so far shows the parser accepting an image that breaks this. The Windows 11 run above confirms that the branch builds and its tests pass. It does not show these cases can happen. A synthetic image (no game files) that the parser accepts and that reaches one of them would settle it.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by StExpeditus on 2026-11-25T09:07:24Z.
Validated the fork branch on Windows 11 Pro 26200 (Intel Core i5-14600K, Rust 1.98.1 MSVC), commit
5edb22b:cargo test -p victory-loader --locked-> 43 passed, 0 failed (the 13windows::tests included).cargo clippy -p victory-loader --all-targets --locked -- -D warnings-> clean.cargo fmt -p victory-loader -- --checkflagscrash.rs:71, which the branch inherits from its base (ffe310e); the same drift exists on current main under this toolchain, andwindows.rsitself is fmt-clean.940d32f6): the onlyvictory-loaderdelta is the 413-line change towindows.rsitself, no unrelated churn.No game files used; synthetic tests only. The fix looks ready to cherry-pick.