fix(libkernel): accept socket option values longer than an int #4658
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4658"
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 milescoviello on 2026-10-12T18:05:49Z.
What
setsockopt()on a guest socket failed withEINVALunless the option length was exactlysizeof(int), so an integer option passed in a wider variable (int64_t,size_t,long) was rejected and silently left unchanged:SO_BROADCASTstayed off andSO_RCVBUF/SO_SNDBUFkept their size.FreeBSD 11.4 reads these options through
sooptcopyin()withsizeof(int)as both the wanted and the minimum length, and only a shorter value fails (sys/kern/uipc_socket.c):sosetopt()readsSO_BROADCAST,SO_REUSEADDR,SO_SNDBUFandSO_RCVBUFwithsooptcopyin(sopt, &optval, sizeof optval, sizeof optval). A longer value now sets the option from its firstint; a shorter one still fails withEINVAL. libSceNet sockets reached through this export already accept lengths of 4 or more.Tested
Ubuntu 24.04, GCC 13.3 (CI's compiler), Release with CI's configure flags, on
main2a5eca11.guest_udpnow setsSO_BROADCASTfrom an 8-byte 0 and then an 8-byte 1 and reads each value back, and checks that a 2-byte value still fails withEINVAL.Udp.cppthe test aborts (setsockoptwith the 8-byte value returns -1,errno22).guest_udppasses; allguest_*tests exceptguest_video_out_*: 306/306 passed in eight consecutive runs (one earlier run had a single failure in another test that I could not identify or reproduce).Not tested on Windows.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-12T18:13:20Z.
Windows test of head
eb9da23e6merged onto currentmain(2a5eca11c, clean merge): Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release,-j2.guest_udp(the test this PR changes:SO_BROADCASTfrom an 8-byte 0 and 1, read back, and a 2-byte value still failing withEINVAL) builds and passes. Only that target was rebuilt for this run; the other socket tests I ran with it (guest_tcp,guest_socket_*,guest_poll,guest_dup,guest_sce_net, 21 of 21 pass) come from earlier builds of the same tree, so they do not exercise this change.Not checked: that
guest_udpfails without the change on Windows (the PR reports it on Linux), the WinsockSO_RCVBUF/SO_SNDBUFpath with a longer value beyond whatguest_udpcovers, Linux, a title run.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T22:18:19Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libkernel/Socket/src/Udp.cppL597-601