Skip to content

HLE/net: refuse a WSAConnectByList count the list cannot back - #476

Closed
iloveslopware wants to merge 1 commit into
fxceless:mainfrom
iloveslopware:wsaconnectbylist-count
Closed

iloveslopware wants to merge 1 commit into
fxceless:mainfrom
iloveslopware:wsaconnectbylist-count

Conversation

@iloveslopware

Copy link
Copy Markdown

WSAConnectByList turned iAddressCount into a &[SocketAddress] of that length before any address was vetted, so a list holding one 16-byte entry with iAddressCount = 0x7FFFFFFF produced a ~34 GB slice and read far past the title's allocation as pointers and lengths — undefined behavior before reachable() could weigh in (#428).

A SOCKET_ADDRESS_LIST carries no size the count could be checked against, so the count is the title's word alone. More candidates than any title offers (MAX_CONNECT_LIST, 64) are now refused with WSAEINVAL and a FALSE return — the same fail-closed posture as the rest of this module — while honest lists reach the host unchanged and the vetting loop is untouched.

The new test builds a one-entry list whose count claims i32::MAX and asserts the call returns 0 with WSAEINVAL set, refusing before the entries are walked.

Fixes #428.

Verification:

  • cargo clippy --target x86_64-pc-windows-msvc --workspace --all-targets --locked -- -D warnings (clang-cl 23.1.5, cross-checked from Linux) passes on default features and on --all-features; this compiles the new test, which then runs in this repo's Windows CI.
  • This module is #[cfg(windows)]-gated, so the Linux build is untouched by construction; main's pre-existing non-Windows test-compile gaps are outside this change and covered by Linux: finish the non-Windows build and tests #449.

No formatting-only churn: one const with its rationale, a four-line guard, one test.


Disclosure: written with AI assistance (GLM via OpenCode) — the fix, test, and cross-verification were drafted and run with the tool, following the report in #428. Reviewed and understood by the human submitting it.

The count became a &[SocketAddress] of that length before any address
was vetted, so one real 16-byte entry with iAddressCount = 0x7FFFFFFF
made a ~34 GB slice and read past the allocation as pointers and
lengths. A SOCKET_ADDRESS_LIST carries no size to check the count
against, so more candidates than any title offers (64) are now refused
with WSAEINVAL instead of walked: the call fails closed like every
other vetted path in this module, and honest lists still reach the
host unchanged.

Fixes fxceless#428.

Copy link
Copy Markdown

Is this a duplicate of #466?

Both address #428 by rejecting oversized WSAConnectByList counts.

This is an automated message. If you believe it is incorrect, please reply with the relevant technical differences.

@iloveslopware

Copy link
Copy Markdown
Author

Yes — #466 was opened five minutes before this one and covers the same defect more completely: it also refuses a negative iAddressCount (which this change left falling to 0 and forwarding the list to the host unvetted), and it reads the entries one at a time with read_unaligned rather than forming a &[SocketAddress]. Its tests cover more ground too, including the host-connect path on real hardware. The cap (64) and the failure mode (WSAEINVAL + FALSE) are identical, so there is nothing here that #466 lacks — closing in its favor.

RecompLive pushed a commit to RecompLive/victory-fork that referenced this pull request Nov 25, 2026
…hout-hint

Census: deduplicate PE imports without hint
oceansde012 pushed a commit to oceansde012/victory-gta6 that referenced this pull request Nov 25, 2026
…hout-hint

Census: deduplicate PE imports without hint
(cherry picked from commit 2d8cac2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[HLE/net] WSAConnectByList builds an unbounded slice from a title-supplied count

2 participants