Skip to content

fix(libkernel): fail a short or long socket address like FreeBSD - #8154

Merged
oneandonlydean merged 2 commits into
boykopovar:mainfrom
xXPBSXx:fix/socket-address-length-v4
Oct 20, 2026
Merged

oneandonlydean merged 2 commits into
boykopovar:mainfrom
xXPBSXx:fix/socket-address-length-v4

Conversation

@xXPBSXx

@xXPBSXx xXPBSXx commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

What

Address() (Udp.cpp, used by bind, connect and sendto) now checks the length first like FreeBSD 11.4 getsockaddr: above 255 bytes ENAMETOOLONG, below 2 EINVAL, then a null pointer EFAULT; an AF_INET address below 16 or an AF_INET6 address below 28 bytes fails with EINVAL instead of EAFNOSUPPORT. Debt entry added for what stays different (an address longer than sockaddr_in/sockaddr_in6 is still accepted; other families still EAFNOSUPPORT).
Fixes #8153

Tested

Windows 10 (19045), MinGW-w64 GCC 15.2.0, Release, on upstream/main 34b1b77 + this branch:

  • guest_socket_address_length: Exit code 0xc0000409 without the change to Udp.cpp, passes with it.
  • The 12 other socket tests (guest_socket_options, _stream_options, _timeouts, _read_write, _port_zero, _pair, _descriptors, _events, _connect_listening, _descriptor_flags, _error, guest_udp) pass.
  • python tools/check_conventions.py --base upstream/main: passes.
  • Not tested: Linux, a console, a title run.

Checklist

  • Based on current main; no open PR touches socket address validation (searched: only closed fix(libkernel): fail a short or long socket address like FreeBSD #4920, the earlier version)
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw; no silent stubs added
  • No notes, investigation .md files or images added to the repository
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • AI-assisted: yes

AI-assisted (Claude Code).

🤖 Generated with Claude Code

xXPBSXx and others added 2 commits October 20, 2026 02:30
bind, connect and sendto answered EFAULT for an address length below 2 and EAFNOSUPPORT for an AF_INET address below 16 or an AF_INET6 address below 28 bytes. FreeBSD 11.4's getsockaddr fails a length below 2 with EINVAL and above SOCK_MAXADDRLEN (255) with ENAMETOOLONG, and the protocols compare the length with sizeof(struct sockaddr_in) or sockaddr_in6 and fail with EINVAL.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ess_length

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 4972 core/libs/prx/libkernel/CMakeLists.txt
PR 5021 core/libs/prx/libkernel/CMakeLists.txt
core/libs/prx/libkernel/Socket/src/Udp.cpp
docs/dev/debt/libkernel.md
PR 6044 core/libs/prx/libkernel/CMakeLists.txt
PR 6149 docs/dev/debt/libkernel.md
PR 6226 core/libs/prx/libkernel/CMakeLists.txt
PR 6469 core/libs/prx/libkernel/CMakeLists.txt
docs/dev/debt/libkernel.md
PR 6519 docs/dev/debt/libkernel.md
PR 6740 docs/dev/debt/libkernel.md
PR 6977 core/libs/prx/libkernel/CMakeLists.txt
core/libs/prx/libkernel/Socket/src/Udp.cpp
docs/dev/debt/libkernel.md
PR 7049 docs/dev/debt/libkernel.md
PR 7088 core/libs/prx/libkernel/Socket/src/Udp.cpp
docs/dev/debt/libkernel.md
PR 7105 docs/dev/debt/libkernel.md
PR 7121 docs/dev/debt/libkernel.md
PR 7149 docs/dev/debt/libkernel.md
PR 7192 core/libs/prx/libkernel/CMakeLists.txt
docs/dev/debt/libkernel.md
PR 7201 core/libs/prx/libkernel/CMakeLists.txt
core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 7509 docs/dev/debt/libkernel.md
PR 7554 docs/dev/debt/libkernel.md
PR 7556 docs/dev/debt/libkernel.md
PR 7605 core/libs/prx/libkernel/Socket/src/Udp.cpp
docs/dev/debt/libkernel.md
PR 7949 docs/dev/debt/libkernel.md

@github-actions github-actions Bot added libkernel build docs fix error Closes an issue (Fixes #N) labels Oct 20, 2026
@oneandonlydean oneandonlydean self-assigned this Oct 20, 2026
@oneandonlydean
oneandonlydean merged commit ebb8610 into boykopovar:main Oct 20, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build docs fix error Closes an issue (Fixes #N) libkernel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

libkernel: bind/connect/sendto accept a socket address of any length

2 participants