libkernel: getsockname on an unbound socket fails with EINVAL on Windows (FreeBSD returns the wildcard address); fix branch ready #3943
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 boykopovar/AnyPS5. Originally posted by husseinkad on 2026-10-11T19:30:29Z.
On Windows,
getsocknameon a socket that has not been bound fails withEINVAL(WinsockWSAEINVAL). FreeBSD 11.4 succeeds:in_getsockaddrandin6_getsockaddrreturn the wildcard address with port 0 (length 16 and family 2 for AF_INET, length 28 and family 28 for AF_INET6). Linux already does this, so a guest that callsgetsocknamebeforebindorconnect(for example to read an ephemeral port later) works on Linux and fails on Windows.Fix branch: https://github.com/husseinkad/AnyPS5/tree/fix/kernel-socket-getsockname-unbound (one commit on current main,
Socket/src/Udp.cppandtests/GuestTcp.cpp). When Winsock reportsWSAEINVALthe call now returns the zero address of the socket's family.Checks:
guest_tcpcase covers TCP and UDP, IPv4 and IPv6; it fails on main (assertion abort) and passes with the change;guest_(tcp|udp|poll|socket|dup)pass.connectare unchanged;getpeernameon an unconnected socket still givesENOTCONN(57).check_conventions.pyis clean andpr_overlap.pyfinds no overlap.Caveats: the new test needs an IPv6 socket to be creatable, so it would fail on a runner with IPv6 disabled (#2820 describes that setup). Only Windows was built and run; on Linux the code is not reached.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T07:37:50Z.
Closing: fixed by #3947. Reopen if
getsocknameon an unbound socket still fails on current main.