HLE/net: bound and check WSAConnectByList entries (#428) #498
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/498"
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?
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:
AI use: written and tested with AI assistance; reviewed before posting. No game files were used.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.