fix(libSceNet): convert sceNetInetPton text and null outputs as measured on a PS5 #10275

Merged
orezraey merged 3 commits from upstream-pr/10275 into main 2026-10-23 23:43:39 +00:00
orezraey commented 2026-10-23 16:25:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by orezraey on 2026-10-23T16:25:54Z.


What

sceNetInetPton and sceNetInetPtonEx measured on a retail PS5 (firmware 13.60) through libSceNet.sprx from a payload process. The sources and console logs are in this gist (pnet to pnet4). The debt entries only had PS4 firmware 10.71 results.

The console:

  • ends IPv4 text at the first space, tab, LF, VT, FF or CR for both functions, as on the PS4, and leaves the output and sceNetErrnoLoc alone when a conversion fails;
  • reads the dotted IPv4 part of IPv6 text with the same IPv4 rules, so "::ffff:1.2.3.4 x", "::1.2.3.4 " and "1:2:3:4:5:6:1.2.3.4 z" convert while "::1 x", "::ffff ", "::ffff:1.2.3.4x" and "::ffff:01.2.3.4" fail;
  • converts IPv4 text with a null dst, returning 1 or 0 without writing and without setting an errno, for both functions;
  • returns NET_EINVAL with errno 22 for a null src, IPv6 included;
  • crashes the process for IPv6 text with a null dst.

AnyPS5 failed IPv6 text with anything after the address, accepted "::ffff:01.2.3.4" on Windows (the host's InetPton allows the leading zero there) and returned NET_EINVAL for a null dst. It now trims IPv6 text with a dotted tail at the first whitespace, checks that tail as an IPv4 address, and converts IPv4 text without an output. IPv6 with a null dst keeps NET_EINVAL instead of the crash; both debt entries say so.

Tested

Windows 11, MinGW (winlibs).

  • guest_sce_net checks the IPv6 dotted tails, the rejected forms, the null outputs and the null IPv6 source, and passes three runs in a row.
  • tools/check_conventions.py passes.
  • tools/pr_overlap.py: #8658, #9231, #9494, #9578, #9727 touch nearby lines; whichever lands second keeps both.

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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4985938234 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10275). Originally posted by [orezraey](https://github.com/orezraey) on 2026-10-23T16:25:54Z. --- ### What `sceNetInetPton` and `sceNetInetPtonEx` measured on a retail PS5 (firmware 13.60) through `libSceNet.sprx` from a payload process. The sources and console logs are in [this gist](https://gist.github.com/orezraey/973f5c6ba18f2cdd3f05d4a6144e5cab) (`pnet` to `pnet4`). The debt entries only had PS4 firmware 10.71 results. The console: - ends IPv4 text at the first space, tab, LF, VT, FF or CR for both functions, as on the PS4, and leaves the output and `sceNetErrnoLoc` alone when a conversion fails; - reads the dotted IPv4 part of IPv6 text with the same IPv4 rules, so `"::ffff:1.2.3.4 x"`, `"::1.2.3.4 "` and `"1:2:3:4:5:6:1.2.3.4 z"` convert while `"::1 x"`, `"::ffff "`, `"::ffff:1.2.3.4x"` and `"::ffff:01.2.3.4"` fail; - converts IPv4 text with a null `dst`, returning 1 or 0 without writing and without setting an errno, for both functions; - returns `NET_EINVAL` with errno 22 for a null `src`, IPv6 included; - crashes the process for IPv6 text with a null `dst`. AnyPS5 failed IPv6 text with anything after the address, accepted `"::ffff:01.2.3.4"` on Windows (the host's `InetPton` allows the leading zero there) and returned `NET_EINVAL` for a null `dst`. It now trims IPv6 text with a dotted tail at the first whitespace, checks that tail as an IPv4 address, and converts IPv4 text without an output. IPv6 with a null `dst` keeps `NET_EINVAL` instead of the crash; both debt entries say so. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Windows 11, MinGW (winlibs). - `guest_sce_net` checks the IPv6 dotted tails, the rejected forms, the null outputs and the null IPv6 source, and passes three runs in a row. - `tools/check_conventions.py` passes. - `tools/pr_overlap.py`: #8658, #9231, #9494, #9578, #9727 touch nearby lines; whichever lands second keeps both. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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
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!10275
No description provided.