fix(libkernel): return the zero address for unbound getsockname on Windows #3947

Merged
MarcZX10 merged 1 commit from upstream-pr/3947 into main 2026-10-13 04:54:53 +00:00
MarcZX10 commented 2026-10-11 19:38:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T19:38:18Z.


What

Carries Hussein Kadhim's fix for #3943, preserving the original commit author. On Windows, an unbound IPv4 or IPv6 socket can make Winsock getsockname return WSAEINVAL; the guest call now returns the zero address for that socket family. The regression test covers TCP and UDP sockets for both families and checks the address length, family, zeroed bytes, and buffer boundary.

Tested

  • Linux, GCC 12.2.0, Release, BUILD_TESTING=ON: built guest_tcp_tests; guest_tcp passed 1/1. Linux does not enter the Windows-specific fallback.
  • The issue author reports that the new test fails on the unmodified Windows branch and passes with the change, along with the guest_tcp, guest_udp, guest_poll, guest_socket, and guest_dup tests.
  • tools/check_conventions.py --base upstream/main and git diff --check passed.
  • No title run reported.

Checklist

  • Based on current main; no other open PR implements this behavior
  • One topic per PR; follow-ups go in a new PR
  • No source comments added
  • Unsupported paths retain explicit errors
  • No investigation notes added
  • No new third-party code
  • Generic behavior, not title-specific
  • Depends on: none
  • AI-assisted: yes; original contributor's commit and attribution preserved
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4821781661 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3947). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-11T19:38:18Z. --- ### What Carries Hussein Kadhim's fix for #3943, preserving the original commit author. On Windows, an unbound IPv4 or IPv6 socket can make Winsock `getsockname` return `WSAEINVAL`; the guest call now returns the zero address for that socket family. The regression test covers TCP and UDP sockets for both families and checks the address length, family, zeroed bytes, and buffer boundary. ### Tested - Linux, GCC 12.2.0, Release, `BUILD_TESTING=ON`: built `guest_tcp_tests`; `guest_tcp` passed 1/1. Linux does not enter the Windows-specific fallback. - The issue author reports that the new test fails on the unmodified Windows branch and passes with the change, along with the `guest_tcp`, `guest_udp`, `guest_poll`, `guest_socket`, and `guest_dup` tests. - `tools/check_conventions.py --base upstream/main` and `git diff --check` passed. - No title run reported. ### Checklist - [x] Based on current `main`; no other open PR implements this behavior - [x] One topic per PR; follow-ups go in a new PR - [x] No source comments added - [x] Unsupported paths retain explicit errors - [x] No investigation notes added - [x] No new third-party code - [x] Generic behavior, not title-specific - [x] Depends on: none - [x] AI-assisted: yes; original contributor's commit and attribution preserved
LeandroLP23 commented 2026-10-11 20:43:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-11T20:43:52Z.


Windows run of this head (41e933562, on main a11c8f7f7): Windows 11 (26300), WinLibs GCC 15.2.0 r7, Release, full build.

  • guest_tcp, guest_udp, guest_socket_read_write, guest_poll, guest_socket_pair, guest_dup and guest_socket_events: 7/7 pass in 3 runs.
  • With Udp.cpp reverted to main, guest_tcp aborts (0xc0000409) in the new UnboundSocketNameIsZero test, so on Windows the test catches the bug and the fix is what makes it pass.
  • Merge note: this PR, #3957 and #3958 each add their test call at the top of main() in GuestTcp.cpp, so any two of them conflict there (Udp.cpp merges cleanly). The second and third to land will need a small rebase.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6113548738 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3947#issuecomment-6113548738). Originally posted by [LeandroLP23](https://github.com/LeandroLP23) on 2026-10-11T20:43:52Z. --- Windows run of this head (`41e933562`, on `main` `a11c8f7f7`): Windows 11 (26300), WinLibs GCC 15.2.0 r7, Release, full build. - `guest_tcp`, `guest_udp`, `guest_socket_read_write`, `guest_poll`, `guest_socket_pair`, `guest_dup` and `guest_socket_events`: 7/7 pass in 3 runs. - With `Udp.cpp` reverted to `main`, `guest_tcp` aborts (`0xc0000409`) in the new `UnboundSocketNameIsZero` test, so on Windows the test catches the bug and the fix is what makes it pass. - Merge note: this PR, #3957 and #3958 each add their test call at the top of `main()` in `GuestTcp.cpp`, so any two of them conflict there (`Udp.cpp` merges cleanly). The second and third to land will need a small rebase.
oneandonlydean commented 2026-10-12 08:24:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-12T08:24:37Z.


Conflicts with main in core/libs/tests/GuestTcp.cpp since #3957 went in; please rebase.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6120526825 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3947#issuecomment-6120526825). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-12T08:24:37Z. --- Conflicts with main in `core/libs/tests/GuestTcp.cpp` since #3957 went in; please rebase.
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
boykopovar/AnyPS5!3947
No description provided.