Loader: fix 4 bounds and cleanup bugs in windows.rs with unit tests #1047
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#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?
@geiyiliyabumo on GitHub · 2026-11-24 15:16 UTC · original
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.
@Marvisak on GitHub · 2026-11-25 06:52 UTC · original · edited 2026-11-25 09:58 UTC
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
@StExpeditus on GitHub · 2026-11-25 09:07 UTC · original
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.