Net: connect/WSAConnect with a zero address are refused as off-machine instead of disconnecting a datagram socket #891
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#891
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?
@BastienRodz on GitHub · 2026-11-24 13:33 UTC · original
What's wrong
crates/victory-hle/src/modules/net.rsvets everyconnect(crates/victory-hle/src/modules/net.rs:223-224) andWSAConnect(crates/victory-hle/src/modules/net.rs:230-239) call throughreachable(crates/victory-hle/src/modules/net.rs:147), which rejects anysockaddrthat does not parse as a loopback IP withSOCKET_ERRORandWSAENETUNREACHbefore calling the host.Under Winsock, a zero address is documented to disconnect a connectionless socket (and fail with
WSAEADDRNOTAVAILon a connection-oriented socket) rather than connect off-machine:connect(Remarks):WSAConnect(Remarks):With a UDP socket connected to a loopback peer, calling
WSAConnectwith an all-zeroSOCKADDR_IN(orconnectwithAF_INET0.0.0.0) returns0and disconnects the socket on Windows; VIctory instead returnsSOCKET_ERRORwithWSAENETUNREACHand leaves the socket connected to the old peer.Impact
Low impact: a title that disconnects a connected datagram socket to reuse it fails to disconnect and keeps sending to the previous peer. Letting zero-address disconnects reach the host does not weaken the offline policy because a zero address never leaves the machine.
Fix
Add a
zero_addresshelper incrates/victory-hle/src/modules/net.rsthat recognizes an all-zerosockaddras well asAF_INETwith0.0.0.0andAF_INET6with::, and bypassreachableinconnectandWSAConnectwhen it returnstrueso the call is forwarded to the host as for loopback.The fix is ready on a branch of my fork, since PR creation is limited to collaborators: https://github.com/BastienRodz/VIctory/commits/hle/zero-address-disconnects (one commit on
mainffe310e,net.rs+81/-3).Tests
zero_address_recognises_disconnect_forms: a zeroedsockaddr,0.0.0.0and::count as zero addresses; loopback,8.8.8.8,::1, null and short lengths don't.zero_address_disconnects_datagram_socket: a UDP socket connected to a loopback peer, thenWSAConnectwith an all-zeroSOCKADDR_IN, returns 0. A followingsendfails withWSAENOTCONN, so the socket really is disconnected.connectwithAF_INET0.0.0.0is passed to the host instead of refused.On
main: the all-zeroWSAConnectreturnsSOCKET_ERRORwithWSAENETUNREACH, fromreachable, before reaching the host.On GitHub's
windows-latest, with the upstream CI's commands (clippy-D warningswith and without--all-features, thencargo test --workspace --locked), everything passes. That includes both new tests and the existingonly_loopback_is_reachable, so the offline policy is unchanged.victory-hle: 96 passed, 0 failed (https://github.com/BastienRodz/VIctory/actions/runs/45404306005).Under Wine,
connectwithAF_INET0.0.0.0goes through to Linux rather than disconnecting, so the test only checks there that the call isn't refused.No game data used. AI-assisted: found with GPT-6.2 Astra, written with Gemini 4 Neon, reviewed and verified with Claude Code.
@DenRakEiw on GitHub · 2026-11-24 14:08 UTC · original
Independent Windows 11 verification of
5d66c30(BastienRodz/VIctory@hle/zero-address-disconnects, fast-forward onmainffe310e) on Windows 11 x64 (Rust 1.98.1 MSVC):cargo test -p victory-hle: 96 passed, 0 failed (plusno_dll_planting: 1 passed), including both new testsmodules::net::tests::zero_address_recognises_disconnect_formsandmodules::net::tests::zero_address_disconnects_datagram_socket(andonly_loopback_is_reachablestays green)cargo clippy -p victory-hle --all-targets: 0 warningscargo xtask policy: okConfirmed that
zero_addresspasses zero-address disconnects cleanly to host Winsock without weakening the offline loopback policy.AI-assisted (Gemini 4 Neon).
@Marvisak on GitHub · 2026-11-25 06:56 UTC · original
Automated triage for the maintainers.
Confirmed on
main. Incrates/victory-hle/src/modules/net.rs,connect,WSAConnectand the other connect paths go throughreachable, which lets only a loopback address through. An all-zerosockaddror0.0.0.0/::is refused withWSAENETUNREACHbefore the host sees it, so a datagram socket can't be disconnected. Open PR #2066 ("Net: forward zero-address datagram disconnects", which names this issue) carries the change, so review can continue there. Your branchhle/zero-address-disconnectscan be compared with it.Generated by Claude Code