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

Merged
xXPBSXx merged 2 commits from upstream-pr/8154 into main 2026-10-20 02:53:11 +00:00
xXPBSXx commented 2026-10-20 00:48:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-20T00:48:08Z.


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 34b1b77abf + 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 #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

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4929392344 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8154). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-20T00:48:08Z. --- ### What `Address()` (Udp.cpp, used by bind, connect and sendto) now checks the length first like FreeBSD 11.4 [`getsockaddr`](https://github.com/freebsd/freebsd-src/blob/release/11.4.0/sys/kern/uipc_syscalls.c#L1769): 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` 34b1b77abf + 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 - [x] Based on current `main`; no open PR touches socket address validation (searched: only closed #4920, the earlier version) - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw; no silent stubs added - [x] No notes, investigation `.md` files or images added to the repository - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] AI-assisted: yes AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-20 00:58:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-20T00:58:13Z.


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
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6280802800 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8154#issuecomment-6280802800). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-20T00:58:13Z. --- <!-- pr-overlap --> 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](https://www.github.com/boykopovar/AnyPS5/pull/4972) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `core/libs/prx/libkernel/CMakeLists.txt`<br>`core/libs/prx/libkernel/Socket/src/Udp.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 6149](https://www.github.com/boykopovar/AnyPS5/pull/6149) | `docs/dev/debt/libkernel.md` | | [PR 6226](https://www.github.com/boykopovar/AnyPS5/pull/6226) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 6469](https://www.github.com/boykopovar/AnyPS5/pull/6469) | `core/libs/prx/libkernel/CMakeLists.txt`<br>`docs/dev/debt/libkernel.md` | | [PR 6519](https://www.github.com/boykopovar/AnyPS5/pull/6519) | `docs/dev/debt/libkernel.md` | | [PR 6740](https://www.github.com/boykopovar/AnyPS5/pull/6740) | `docs/dev/debt/libkernel.md` | | [PR 6977](https://www.github.com/boykopovar/AnyPS5/pull/6977) | `core/libs/prx/libkernel/CMakeLists.txt`<br>`core/libs/prx/libkernel/Socket/src/Udp.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 7049](https://www.github.com/boykopovar/AnyPS5/pull/7049) | `docs/dev/debt/libkernel.md` | | [PR 7088](https://www.github.com/boykopovar/AnyPS5/pull/7088) | `core/libs/prx/libkernel/Socket/src/Udp.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 7105](https://www.github.com/boykopovar/AnyPS5/pull/7105) | `docs/dev/debt/libkernel.md` | | [PR 7121](https://www.github.com/boykopovar/AnyPS5/pull/7121) | `docs/dev/debt/libkernel.md` | | [PR 7149](https://www.github.com/boykopovar/AnyPS5/pull/7149) | `docs/dev/debt/libkernel.md` | | [PR 7192](https://www.github.com/boykopovar/AnyPS5/pull/7192) | `core/libs/prx/libkernel/CMakeLists.txt`<br>`docs/dev/debt/libkernel.md` | | [PR 7201](https://www.github.com/boykopovar/AnyPS5/pull/7201) | `core/libs/prx/libkernel/CMakeLists.txt`<br>`core/libs/prx/libkernel/Socket/src/Udp.cpp` | | [PR 7509](https://www.github.com/boykopovar/AnyPS5/pull/7509) | `docs/dev/debt/libkernel.md` | | [PR 7554](https://www.github.com/boykopovar/AnyPS5/pull/7554) | `docs/dev/debt/libkernel.md` | | [PR 7556](https://www.github.com/boykopovar/AnyPS5/pull/7556) | `docs/dev/debt/libkernel.md` | | [PR 7605](https://www.github.com/boykopovar/AnyPS5/pull/7605) | `core/libs/prx/libkernel/Socket/src/Udp.cpp`<br>`docs/dev/debt/libkernel.md` | | [PR 7949](https://www.github.com/boykopovar/AnyPS5/pull/7949) | `docs/dev/debt/libkernel.md` |
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!8154
No description provided.