HLE/net: bound and check WSAConnectByList entries (#428) #498

Open
axolotlpriv wants to merge 1 commit from upstream-pr/498 into main
axolotlpriv commented 2026-11-25 01:45:21 +00:00 (Migrated from github.com)

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


What

WSAConnectByList built &[SocketAddress] directly from the title-supplied iAddressCount via std::slice::from_raw_parts, with no count bound, alignment guarantee, or readability check. A negative/zero or oversized count (such as x7fffffff on a single-entry buffer) either skipped vetting or constructed an out-of-bounds slice over unmapped or unrelated memory.

WSAConnectByList now checks that the list header is committed and readable, rejects counts outside 1..=64 with WSAEINVAL, and walks entries one by one with wrapping_add, VirtualQuery readability checks (WSAEFAULT on unreadable pages), and
ead_unaligned(). socket_addr likewise validates readability and reads unaligned headers/addresses instead of slicing len bytes blindly, and ind copies only the verified sockaddr bytes.

Fixes #428.

Testing

Added modules::net::tests::connect_by_list_validates_count_and_bounds covering i32::MAX, , -1, i32::MIN, and 65 counts (WSAEINVAL), a two-page PAGE_NOACCESS guard fixture catching truncated lists and unreadable headers (WSAEFAULT) as well as unreadable sockaddr pointers (WSAENETUNREACH), an unaligned [HOME, AWAY] list (WSAENETUNREACH), and a valid loopback connection. Existing tests pass unchanged.

Validated locally on Windows:

  • cargo clippy --workspace --all-targets --locked -- -D warnings
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
  • cargo test --workspace --locked
  • cargo xtask policy

AI use: written and tested with AI assistance; reviewed before posting. No game files were used.

<!-- greyfinch-sync:fxceless/victory-fork:issue:6595223152 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/498). Originally posted by [axolotlpriv](https://github.com/axolotlpriv) on 2026-11-25T01:45:21Z. --- ## What WSAConnectByList built &[SocketAddress] directly from the title-supplied iAddressCount via std::slice::from_raw_parts, with no count bound, alignment guarantee, or readability check. A negative/zero or oversized count (such as x7fffffff on a single-entry buffer) either skipped vetting or constructed an out-of-bounds slice over unmapped or unrelated memory. WSAConnectByList now checks that the list header is committed and readable, rejects counts outside 1..=64 with WSAEINVAL, and walks entries one by one with wrapping_add, VirtualQuery readability checks (WSAEFAULT on unreadable pages), and ead_unaligned(). socket_addr likewise validates readability and reads unaligned headers/addresses instead of slicing len bytes blindly, and ind copies only the verified sockaddr bytes. Fixes #428. ## Testing Added modules::net::tests::connect_by_list_validates_count_and_bounds covering i32::MAX, , -1, i32::MIN, and 65 counts (WSAEINVAL), a two-page PAGE_NOACCESS guard fixture catching truncated lists and unreadable headers (WSAEFAULT) as well as unreadable sockaddr pointers (WSAENETUNREACH), an unaligned [HOME, AWAY] list (WSAENETUNREACH), and a valid loopback connection. Existing tests pass unchanged. Validated locally on Windows: - cargo clippy --workspace --all-targets --locked -- -D warnings - cargo clippy --workspace --all-targets --all-features --locked -- -D warnings - cargo test --workspace --locked - cargo xtask policy **AI use:** written and tested with AI assistance; reviewed before posting. No game files were used.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/498:upstream-pr/498'
git switch 'upstream-pr/498'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/498'
git switch 'upstream-pr/498'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/498'
git switch 'upstream-pr/498'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/498'
git switch 'main'
git merge --squash 'upstream-pr/498'
git switch 'main'
git merge --ff-only 'upstream-pr/498'
git switch 'main'
git merge 'upstream-pr/498'
git push origin 'main'
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!498
No description provided.