Skip to content

fix(libSceNet): name an unbound socket with the zero address on Windows - #4614

Merged
adriadam10 merged 2 commits into
boykopovar:mainfrom
EagleBearerYS:fix/libscenet-getsockname-unbound-windows
Oct 13, 2026
Merged

adriadam10 merged 2 commits into
boykopovar:mainfrom
EagleBearerYS:fix/libscenet-getsockname-unbound-windows

Conversation

@EagleBearerYS

@EagleBearerYS EagleBearerYS commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

What

sceNetGetsockname on a socket that is neither bound nor connected failed with EINVAL (0x80410116, errno 22) on Windows, where Winsock reports WSAEINVAL. FreeBSD 11.4 returns the wildcard address with port 0 (in_getsockaddr, in6_getsockaddr), and Linux already does, so on WSAEINVAL the call now builds that address for the socket's family. This is the libSceNet side of #3943, which describes the same failure for libkernel's getsockname.

Tested

Windows 11 (10.0.26300), WinLibs MinGW-w64 GCC 15.2.0 r7 (UCRT), Release, -DBUILD_TESTING=ON, on main at 2a5eca1:

  • With main's Export.cpp, the new CheckUnboundSocketName in guest_sce_net aborts (exit 0xc0000409); guest_sce_net passes on main itself, IPv6 checks included, so the abort is the new check. With the change it passes, 20 runs in a row. Both the IPv4 and the IPv6 sockets are checked, for TCP and UDP.
  • All 128 tests registered in core/libs/prx/libc/CMakeLists.txt and core/libs/prx/libkernel/CMakeLists.txt that build on Windows pass, and so do the network tests (guest_datagram_recv, guest_datagram_recvfrom, guest_datagram_sceNetRecv, guest_datagram_sceNetRecvfrom, guest_udp, guest_resolver, guest_posix_filesystem).

Linux (Ubuntu 24.04, GCC 13.3, Release), base 33ae282: the new CheckUnboundSocketName in guest_sce_net passes before and after, since Linux already returns the zero address. Again on WSL2 (Ubuntu 24.04, GCC 13.3.0, Release with CI's configure flags), merged into main at c952c2b, IPv6 checks included: it passes with main's Export.cpp and with the change, 20 runs in a row.

tools/check_conventions.py --base origin/main passes.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

sceNetGetsockname on a socket that is neither bound nor connected failed
with EINVAL on Windows, where Winsock reports WSAEINVAL. FreeBSD 11.4
returns the wildcard address with port 0 (in_getsockaddr and
in6_getsockaddr in sys/netinet/in_pcb.c and sys/netinet6/in6_pcb.c), and
Linux already does, so the call now builds that address for the socket's
family.
boykopovar#4785 calls its netstat check right after CheckPoolStats(), so calling CheckUnboundSocketName() there made the two pull requests conflict.
@adriadam10

Copy link
Copy Markdown
Collaborator

Checked the WSAEINVAL fallback in sceNetGetsockname (zero address of the socket's family, other errors unchanged) and CheckUnboundSocketName (IPv4/IPv6, TCP/UDP, length/family/zero bytes); guest_sce_net passes on the merged tree. The Windows behaviour is covered by the full Build's windows job; merging once it is green.

@adriadam10
adriadam10 merged commit cba01c8 into boykopovar:main Oct 13, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants