fix(libSceNet): end IPv4 sceNetInetPton text at whitespace as the PS4 does #7921

Merged
ntamas94 merged 2 commits from upstream-pr/7921 into main 2026-10-19 16:52:51 +00:00
ntamas94 commented 2026-10-19 14:07:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ntamas94 on 2026-10-19T14:07:13Z.


What

sceNetInetPton with AF_INET now ends the text at the first space, tab, LF, VT, FF or CR and converts what comes before it, as the console does. A failed conversion no longer writes to the destination: Winsock inet_pton stores the parsed prefix before it returns 0 ("1.2.3.4x" leaves 01 02 03 04 in the buffer), so the conversion goes through a local buffer and is copied only on success. IPv6 is unchanged.

Measured on a PS4 (firmware 10.71) with an OpenOrbis homebrew that calls sceNetInetPton with the buffer filled with 0xaa and sceNetErrnoLoc set to 123 before each call:

Input PS4 10.71 main (Winsock / glibc)
"1.2.3.4" + space, \t, \n, \v, \f or \r 1, 01020304 0
"1.2.3.4 5", "1.2.3.4 x" 1, 01020304 0
" 1.2.3.4", "1.2.3.4x", "1.2.3.4.", "1.2.3.4\x01", "1.2.3.4\xa0", "1.2. 3.4", "1.2.3 " 0, buffer untouched 0 (Winsock writes the prefix for "1.2.3.4x")
"1.2.3", "01.2.3.4", "256.0.0.1" 0 0
"::1 ", "::1\t", " ::1", "::1x" 0, buffer untouched 0 (Winsock writes ::1 for "::1x")
af = 99 0x8041012f, errno 47 same

sceNetErrnoLoc kept 123 after every call that returned 0 or 1. The PS5 was not measured; the debt entry says so.

Raw output (PS4 firmware 10.71)
firmware ret=0x00000000 string="10.710.001" version=0x10710001
sceNetInetPton v4_ok af=2 src="192.168.1.4" ret=1 (0x00000001) errno=123 dst=c0a80104aaaaaaaaaaaaaaaaaaaaaaaa
sceNetInetPton v4_short af=2 src="1.2.3" ret=0 (0x00000000) errno=123 dst=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
sceNetInetPton v4_octet_256 af=2 src="256.0.0.1" ret=0 (0x00000000) errno=123 dst=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
sceNetInetPton v4_leading_zero af=2 src="01.2.3.4" ret=0 (0x00000000) errno=123 dst=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
sceNetInetPton v4_trailing_space af=2 src="1.2.3.4 " ret=1 (0x00000001) errno=123 dst=01020304aaaaaaaaaaaaaaaaaaaaaaaa
sceNetInetPton v4_trailing_tab af=2 src="1.2.3.4\t" ret=1 (0x00000001) errno=123 dst=01020304aaaaaaaaaaaaaaaaaaaaaaaa
sceNetInetPton v4_trailing_lf af=2 src="1.2.3.4\n" ret=1 (0x00000001) errno=123 dst=01020304aaaaaaaaaaaaaaaaaaaaaaaa
sceNetInetPton v4_trailing_cr af=2 src="1.2.3.4\r" ret=1 (0x00000001) errno=123 dst=01020304aaaaaaaaaaaaaaaaaaaaaaaa
sceNetInetPton v4_trailing_vt af=2 src="1.2.3.4\x0b" ret=1 (0x00000001) errno=123 dst=01020304aaaaaaaaaaaaaaaaaaaaaaaa
sceNetInetPton v4_trailing_ff af=2 src="1.2.3.4\x0c" ret=1 (0x00000001) errno=123 dst=01020304aaaaaaaaaaaaaaaaaaaaaaaa
sceNetInetPton v4_trailing_0x01 af=2 src="1.2.3.4\x01" ret=0 (0x00000000) errno=123 dst=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
sceNetInetPton v4_trailing_nbsp af=2 src="1.2.3.4\xa0" ret=0 (0x00000000) errno=123 dst=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
sceNetInetPton v4_three_parts_space af=2 src="1.2.3 " ret=0 (0x00000000) errno=123 dst=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
sceNetInetPton v4_ok_space_x af=2 src="1.2.3.4 x" ret=1 (0x00000001) errno=123 dst=01020304aaaaaaaaaaaaaaaaaaaaaaaa
sceNetInetPton v4_leading_space af=2 src=" 1.2.3.4" ret=0 (0x00000000) errno=123 dst=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
sceNetInetPton v4_trailing_x af=2 src="1.2.3.4x" ret=0 (0x00000000) errno=123 dst=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
sceNetInetPton v4_space_then_digit af=2 src="1.2.3.4 5" ret=1 (0x00000001) errno=123 dst=01020304aaaaaaaaaaaaaaaaaaaaaaaa
sceNetInetPton v4_trailing_dot af=2 src="1.2.3.4." ret=0 (0x00000000) errno=123 dst=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
sceNetInetPton v4_inner_space af=2 src="1.2. 3.4" ret=0 (0x00000000) errno=123 dst=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
sceNetInetPton v6_loopback af=28 src="::1" ret=1 (0x00000001) errno=123 dst=00000000000000000000000000000001
sceNetInetPton v6_mapped af=28 src="::ffff:1.2.3.4" ret=1 (0x00000001) errno=123 dst=00000000000000000000ffff01020304
sceNetInetPton v6_trailing_space af=28 src="::1 " ret=0 (0x00000000) errno=123 dst=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
sceNetInetPton v6_trailing_tab af=28 src="::1\t" ret=0 (0x00000000) errno=123 dst=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
sceNetInetPton v6_leading_space af=28 src=" ::1" ret=0 (0x00000000) errno=123 dst=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
sceNetInetPton v6_trailing_x af=28 src="::1x" ret=0 (0x00000000) errno=123 dst=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
sceNetInetPton bad_af af=99 src="1.2.3.4" ret=-2143223505 (0x8041012f) errno=47 dst=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

Tested

Windows 11 Pro (26200), WinLibs GCC 15.2.0 r7: guest_sce_net passes. With Export.cpp from main and the new checks, guest_sce_net fails. Linux not run locally. No title or homebrew run on AnyPS5.

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 under Silent stubs in their library's technical debt file
  • 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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4922235476 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7921). Originally posted by [ntamas94](https://github.com/ntamas94) on 2026-10-19T14:07:13Z. --- ### What `sceNetInetPton` with `AF_INET` now ends the text at the first space, tab, LF, VT, FF or CR and converts what comes before it, as the console does. A failed conversion no longer writes to the destination: Winsock `inet_pton` stores the parsed prefix before it returns 0 (`"1.2.3.4x"` leaves `01 02 03 04` in the buffer), so the conversion goes through a local buffer and is copied only on success. IPv6 is unchanged. Measured on a PS4 (firmware 10.71) with an OpenOrbis homebrew that calls `sceNetInetPton` with the buffer filled with `0xaa` and `sceNetErrnoLoc` set to 123 before each call: | Input | PS4 10.71 | `main` (Winsock / glibc) | |---|---|---| | `"1.2.3.4"` + space, `\t`, `\n`, `\v`, `\f` or `\r` | 1, `01020304` | 0 | | `"1.2.3.4 5"`, `"1.2.3.4 x"` | 1, `01020304` | 0 | | `" 1.2.3.4"`, `"1.2.3.4x"`, `"1.2.3.4."`, `"1.2.3.4\x01"`, `"1.2.3.4\xa0"`, `"1.2. 3.4"`, `"1.2.3 "` | 0, buffer untouched | 0 (Winsock writes the prefix for `"1.2.3.4x"`) | | `"1.2.3"`, `"01.2.3.4"`, `"256.0.0.1"` | 0 | 0 | | `"::1 "`, `"::1\t"`, `" ::1"`, `"::1x"` | 0, buffer untouched | 0 (Winsock writes `::1` for `"::1x"`) | | `af = 99` | `0x8041012f`, errno 47 | same | `sceNetErrnoLoc` kept 123 after every call that returned 0 or 1. The PS5 was not measured; the debt entry says so. <details><summary>Raw output (PS4 firmware 10.71)</summary> ``` firmware ret=0x00000000 string="10.710.001" version=0x10710001 sceNetInetPton v4_ok af=2 src="192.168.1.4" ret=1 (0x00000001) errno=123 dst=c0a80104aaaaaaaaaaaaaaaaaaaaaaaa sceNetInetPton v4_short af=2 src="1.2.3" ret=0 (0x00000000) errno=123 dst=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa sceNetInetPton v4_octet_256 af=2 src="256.0.0.1" ret=0 (0x00000000) errno=123 dst=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa sceNetInetPton v4_leading_zero af=2 src="01.2.3.4" ret=0 (0x00000000) errno=123 dst=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa sceNetInetPton v4_trailing_space af=2 src="1.2.3.4 " ret=1 (0x00000001) errno=123 dst=01020304aaaaaaaaaaaaaaaaaaaaaaaa sceNetInetPton v4_trailing_tab af=2 src="1.2.3.4\t" ret=1 (0x00000001) errno=123 dst=01020304aaaaaaaaaaaaaaaaaaaaaaaa sceNetInetPton v4_trailing_lf af=2 src="1.2.3.4\n" ret=1 (0x00000001) errno=123 dst=01020304aaaaaaaaaaaaaaaaaaaaaaaa sceNetInetPton v4_trailing_cr af=2 src="1.2.3.4\r" ret=1 (0x00000001) errno=123 dst=01020304aaaaaaaaaaaaaaaaaaaaaaaa sceNetInetPton v4_trailing_vt af=2 src="1.2.3.4\x0b" ret=1 (0x00000001) errno=123 dst=01020304aaaaaaaaaaaaaaaaaaaaaaaa sceNetInetPton v4_trailing_ff af=2 src="1.2.3.4\x0c" ret=1 (0x00000001) errno=123 dst=01020304aaaaaaaaaaaaaaaaaaaaaaaa sceNetInetPton v4_trailing_0x01 af=2 src="1.2.3.4\x01" ret=0 (0x00000000) errno=123 dst=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa sceNetInetPton v4_trailing_nbsp af=2 src="1.2.3.4\xa0" ret=0 (0x00000000) errno=123 dst=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa sceNetInetPton v4_three_parts_space af=2 src="1.2.3 " ret=0 (0x00000000) errno=123 dst=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa sceNetInetPton v4_ok_space_x af=2 src="1.2.3.4 x" ret=1 (0x00000001) errno=123 dst=01020304aaaaaaaaaaaaaaaaaaaaaaaa sceNetInetPton v4_leading_space af=2 src=" 1.2.3.4" ret=0 (0x00000000) errno=123 dst=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa sceNetInetPton v4_trailing_x af=2 src="1.2.3.4x" ret=0 (0x00000000) errno=123 dst=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa sceNetInetPton v4_space_then_digit af=2 src="1.2.3.4 5" ret=1 (0x00000001) errno=123 dst=01020304aaaaaaaaaaaaaaaaaaaaaaaa sceNetInetPton v4_trailing_dot af=2 src="1.2.3.4." ret=0 (0x00000000) errno=123 dst=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa sceNetInetPton v4_inner_space af=2 src="1.2. 3.4" ret=0 (0x00000000) errno=123 dst=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa sceNetInetPton v6_loopback af=28 src="::1" ret=1 (0x00000001) errno=123 dst=00000000000000000000000000000001 sceNetInetPton v6_mapped af=28 src="::ffff:1.2.3.4" ret=1 (0x00000001) errno=123 dst=00000000000000000000ffff01020304 sceNetInetPton v6_trailing_space af=28 src="::1 " ret=0 (0x00000000) errno=123 dst=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa sceNetInetPton v6_trailing_tab af=28 src="::1\t" ret=0 (0x00000000) errno=123 dst=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa sceNetInetPton v6_leading_space af=28 src=" ::1" ret=0 (0x00000000) errno=123 dst=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa sceNetInetPton v6_trailing_x af=28 src="::1x" ret=0 (0x00000000) errno=123 dst=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa sceNetInetPton bad_af af=99 src="1.2.3.4" ret=-2143223505 (0x8041012f) errno=47 dst=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ``` </details> ### Tested Windows 11 Pro (26200), WinLibs GCC 15.2.0 r7: `guest_sce_net` passes. With `Export.cpp` from `main` and the new checks, `guest_sce_net` fails. Linux not run locally. No title or homebrew run on AnyPS5. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-19 14:17:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-19T14:17:47Z.


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 5836 core/libs/prx/libSceNet/Export.cpp
core/libs/tests/GuestSceNet.cpp
docs/dev/debt/libSceNet.md
PR 6044 core/libs/tests/GuestSceNet.cpp
PR 7201 core/libs/prx/libSceNet/Export.cpp
PR 7332 core/libs/prx/libSceNet/Export.cpp
core/libs/tests/GuestSceNet.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6269404722 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7921#issuecomment-6269404722). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-19T14:17:47Z. --- <!-- 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 5836](https://www.github.com/boykopovar/AnyPS5/pull/5836) | `core/libs/prx/libSceNet/Export.cpp`<br>`core/libs/tests/GuestSceNet.cpp`<br>`docs/dev/debt/libSceNet.md` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/tests/GuestSceNet.cpp` | | [PR 7201](https://www.github.com/boykopovar/AnyPS5/pull/7201) | `core/libs/prx/libSceNet/Export.cpp` | | [PR 7332](https://www.github.com/boykopovar/AnyPS5/pull/7332) | `core/libs/prx/libSceNet/Export.cpp`<br>`core/libs/tests/GuestSceNet.cpp` |
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!7921
No description provided.