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

Closed
opened 2026-10-20 00:48:03 +00:00 by xXPBSXx · 0 comments
xXPBSXx commented 2026-10-20 00:48:03 +00:00 (Migrated from github.com)
Contributor

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


Repro

Guest calls on Windows: connect(s, addr, 1), bind(s, addr, 0), bind(s, addr, 15) for AF_INET, connect(s6, addr, 20) for AF_INET6, sendto(..., addr, 8), bind(s, addr, 256).
Expected (FreeBSD 11.4 getsockaddr, sys/kern/uipc_syscalls.c:1777-1780): length > 255 -> ENAMETOOLONG (63); length < offsetof(struct sockaddr, sa_data) -> EINVAL (22); plus the family check of the protocol (tcp_usr_connect/in_pcbconnect): AF_INET shorter than 16 or AF_INET6 shorter than 28 -> EINVAL.
Actual: Address() in core/libs/prx/libkernel/Socket/src/Udp.cpp returns EFAULT (14) for length < 2 and EAFNOSUPPORT (47) for a short AF_INET/AF_INET6 address.
Test: core/libs/tests/GuestSocketAddressLength.cpp (fails with 0xc0000409 before the fix).
Fix branch: https://github.com/xXPBSXx/AnyPS5/tree/fix/socket-address-length-v4
AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5933946925 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/8153). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-20T00:48:03Z. --- ### Repro Guest calls on Windows: `connect(s, addr, 1)`, `bind(s, addr, 0)`, `bind(s, addr, 15)` for AF_INET, `connect(s6, addr, 20)` for AF_INET6, `sendto(..., addr, 8)`, `bind(s, addr, 256)`. Expected (FreeBSD 11.4 `getsockaddr`, sys/kern/uipc_syscalls.c:1777-1780): length > 255 -> ENAMETOOLONG (63); length < offsetof(struct sockaddr, sa_data) -> EINVAL (22); plus the family check of the protocol (`tcp_usr_connect`/`in_pcbconnect`): AF_INET shorter than 16 or AF_INET6 shorter than 28 -> EINVAL. Actual: `Address()` in `core/libs/prx/libkernel/Socket/src/Udp.cpp` returns EFAULT (14) for length < 2 and EAFNOSUPPORT (47) for a short AF_INET/AF_INET6 address. Test: `core/libs/tests/GuestSocketAddressLength.cpp` (fails with 0xc0000409 before the fix). Fix branch: https://github.com/xXPBSXx/AnyPS5/tree/fix/socket-address-length-v4 AI-assisted (Claude Code).
Sign in to join this conversation.
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#8153
No description provided.