WSAConnectByList reads at most 64 candidates and refuses a negative count #466

Open
github-bot wants to merge 1 commit from github-bot/gh-466 into main AGit
Owner

@⁠Frtuchinno on GitHub · 2026-11-25 01:17 UTC · original
Frtuchinno:fix/wsaconnectbylist-count → main · +95 −9 · 1 files · 1 commits · open

Fixes #428.

WSAConnectByList took the title's iAddressCount as the length of a slice with no upper bound. A count larger than the number of entries actually present made the vetting loop read whatever memory follows the list as SOCKET_ADDRESS values. A negative count became 0, so the list went on to the host without being vetted.

Change (crates/victory-hle/src/modules/net.rs):

  • A count below zero or above MAX_CONNECT_CANDIDATES (64) fails with WSAEINVAL and the call returns FALSE. Nothing after the count is read, and the host never sees the list. Every candidate has to be loopback, and the host tries them one after another, so a legitimate list is a handful of entries.
  • Entries are read one by one with read_unaligned instead of through a &[SocketAddress]. The loop still stops at the first candidate that isn't loopback (WSAENETUNREACH), as before.

Test: connect_by_list_vets_a_bounded_list covers five lists:

List Result
65 loopback entries WSAEINVAL
count i32::MAX with one entry present WSAEINVAL
count -1 WSAEINVAL
loopback entry + TEST-NET entry WSAENETUNREACH
a single loopback entry the host connects to a local listener

On the old code the 65-entry case reaches the host and connects (left: 1, right: 0), so the test fails there.

Checked on Windows 11 (RX 7800 XT), toolchain 1.98.1 on a803c87:

  • cargo clippy -p victory-hle --all-targets --locked -- -D warnings: clean, with and without --all-features.
  • cargo test -p victory-hle --locked: 97 passed, 0 failed.

No game run: this path isn't reached by the title's normal boot. Only net.rs changes. Running cargo fmt on main also reformats twelve other files in this crate, and those are left out of this PR.

AI-assisted (Claude Code): it wrote the change and the test and ran the checks on my machine. I reviewed it before opening this PR.

🤖 Generated with Claude Code

**@⁠Frtuchinno** on GitHub · 2026-11-25 01:17 UTC · [original](https://github.com/fxceless/victory-fork/pull/466) `Frtuchinno:fix/wsaconnectbylist-count` → `main` · +95 −9 · 1 files · 1 commits · open Fixes #428. `WSAConnectByList` took the title's `iAddressCount` as the length of a slice with no upper bound. A count larger than the number of entries actually present made the vetting loop read whatever memory follows the list as `SOCKET_ADDRESS` values. A negative count became 0, so the list went on to the host without being vetted. **Change** (`crates/victory-hle/src/modules/net.rs`): - A count below zero or above `MAX_CONNECT_CANDIDATES` (64) fails with `WSAEINVAL` and the call returns FALSE. Nothing after the count is read, and the host never sees the list. Every candidate has to be loopback, and the host tries them one after another, so a legitimate list is a handful of entries. - Entries are read one by one with `read_unaligned` instead of through a `&[SocketAddress]`. The loop still stops at the first candidate that isn't loopback (`WSAENETUNREACH`), as before. **Test:** `connect_by_list_vets_a_bounded_list` covers five lists: | List | Result | |---|---| | 65 loopback entries | `WSAEINVAL` | | count `i32::MAX` with one entry present | `WSAEINVAL` | | count `-1` | `WSAEINVAL` | | loopback entry + TEST-NET entry | `WSAENETUNREACH` | | a single loopback entry | the host connects to a local listener | On the old code the 65-entry case reaches the host and connects (`left: 1, right: 0`), so the test fails there. **Checked on** Windows 11 (RX 7800 XT), toolchain 1.98.1 on `a803c87`: - `cargo clippy -p victory-hle --all-targets --locked -- -D warnings`: clean, with and without `--all-features`. - `cargo test -p victory-hle --locked`: 97 passed, 0 failed. No game run: this path isn't reached by the title's normal boot. Only `net.rs` changes. Running `cargo fmt` on `main` also reformats twelve other files in this crate, and those are left out of this PR. AI-assisted (Claude Code): it wrote the change and the test and ran the checks on my machine. I reviewed it before opening this PR. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The count of a SOCKET_ADDRESS_LIST came from the title and became the
length of a slice with no upper bound, so a count past the entries
present read memory after the list as addresses (#428). A count below
zero or above 64 now fails with WSAEINVAL before anything after the
count is read and without the host seeing the list; the entries are read
one by one with read_unaligned instead of through a slice.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:44:00 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/466/head:github-bot/gh-466'
git switch 'github-bot/gh-466'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-466'
git switch 'github-bot/gh-466'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-466'
git switch 'github-bot/gh-466'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-466'
git switch 'main'
git merge --squash 'github-bot/gh-466'
git switch 'main'
git merge --ff-only 'github-bot/gh-466'
git switch 'main'
git merge 'github-bot/gh-466'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.