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

Closed
iloveslopware wants to merge 1 commit from upstream-pr/476 into main
iloveslopware commented 2026-11-25 01:22:43 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by iloveslopware on 2026-11-25T01:22:43Z.


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 #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.

<!-- greyfinch-sync:fxceless/victory-fork:issue:6594939556 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/476). Originally posted by [iloveslopware](https://github.com/iloveslopware) on 2026-11-25T01:22:43Z. --- `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 #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.
upstream-sync closed this pull request 2026-11-25 02:09:40 +00:00
kaayzouee commented 2026-11-25 02:10:09 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by kaayzouee on 2026-11-25T01:41:21Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7149840594 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/476#issuecomment-7149840594). Originally posted by [kaayzouee](https://github.com/kaayzouee) on 2026-11-25T01:41:21Z. --- 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 commented 2026-11-25 02:10:10 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by iloveslopware on 2026-11-25T01:44:37Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7149903316 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/476#issuecomment-7149903316). Originally posted by [iloveslopware](https://github.com/iloveslopware) on 2026-11-25T01:44:37Z. --- 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.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
fxceless/victory-fork!476
No description provided.