fix(libSceNet): follow FreeBSD inet text rules #4886

Closed
EagleBearerYS wants to merge 0 commits from upstream-pr/4886 into main
EagleBearerYS commented 2026-10-13 01:49:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-13T01:49:23Z.


What

On Windows, sceNetInetPton and sceNetInetNtop (libSceNet/Export.cpp) call Winsock's InetPtonA and InetNtopA, whose text rules differ from FreeBSD 11.4's. This is the libSceNet half of #3126. #3530 fixed the same difference in libkernel's inet_pton and inet_ntop, and #3126 notes that the libSceNet calls "still use the host functions and have the same difference".

Measured on this PC with Winsock, which main's functions return as is, and with glibc, whose rules match FreeBSD's:

Call Windows on main Linux, and FreeBSD
sceNetInetNtop of ::ffff:0.0.0.1 ::ffff:0:1 ::ffff:0.0.0.1
sceNetInetNtop of ::ffff:0:102:304 ::ffff:0:1.2.3.4 ::ffff:0:102:304
sceNetInetNtop of fe80::5efe:102:304 fe80::5efe:1.2.3.4 fe80::5efe:102:304
sceNetInetPton of ::01.2.3.4 1 0
sceNetInetPton of ::1.2.3.04 1 0
sceNetInetPton of ::ffff:01.2.3.4 1 0

FreeBSD:

Both functions now convert with libkernel's __inet_pton_nid_postfix and __inet_ntop_nid_postfix. libSceNet's own checks stay:

  • null pointers give EINVAL, and another family gives EAFNOSUPPORT;
  • a short buffer still gives ENOSPC (28) through sceNetErrnoLoc, now taken from libkernel's errno.

The NET_ENOSPC constant had no other use and is removed. Linux already follows these rules through glibc, so nothing changes there. No title is claimed. The new debt entry says that the rules are libkernel's and unverified on a console, as libkernel's own entry does.

Tested

Windows 11 (10.0.26300), WinLibs MinGW-w64 GCC 15.2.0 r7 (UCRT), Release, -DBUILD_TESTING=ON, on main at 0c3dc9ca2:

  • guest_sce_net checks three more round trips with CheckAddressText: ::ffff:0.0.0.1, ::ffff:0:102:304 and fe80::5efe:102:304. Each goes from text to an address and back, with ENOSPC for every buffer shorter than the text.
  • New CheckRejectedAddressText checks that sceNetInetPton returns 0 and leaves the destination untouched for ::01.2.3.4 and ::ffff:01.2.3.4.
  • With main's Export.cpp the test aborts at the first new check, where sceNetInetNtop returns ::ffff:0:1. With the change it passes 20 runs in a row.
  • 147 tests pass:
    • guest_sce_net, guest_memory_pool_stats and guest_resolver;
    • the guest_datagram_* and guest_socket_host_write_* tests;
    • the tests registered in core/libs/prx/libc/CMakeLists.txt and core/libs/prx/libkernel/CMakeLists.txt that build on Windows, libkernel's guest_addresses among them.
  • tools/check_conventions.py --base origin/main passes.
  • Linux: WSL2 (Ubuntu 24.04, GCC 13.3.0, Release with CI's configure flags), same commit. guest_sce_net passes with main's Export.cpp, because glibc already follows these rules. With the change it passes 20 runs in a row.
  • Not tested: macOS, any title.

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
  • Unblocks: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4837208956 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4886). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-13T01:49:23Z. --- ### What On Windows, `sceNetInetPton` and `sceNetInetNtop` (`libSceNet/Export.cpp`) call Winsock's `InetPtonA` and `InetNtopA`, whose text rules differ from FreeBSD 11.4's. This is the libSceNet half of #3126. #3530 fixed the same difference in libkernel's `inet_pton` and `inet_ntop`, and #3126 notes that the libSceNet calls "still use the host functions and have the same difference". Measured on this PC with Winsock, which `main`'s functions return as is, and with glibc, whose rules match FreeBSD's: | Call | Windows on `main` | Linux, and FreeBSD | |---|---|---| | `sceNetInetNtop` of `::ffff:0.0.0.1` | `::ffff:0:1` | `::ffff:0.0.0.1` | | `sceNetInetNtop` of `::ffff:0:102:304` | `::ffff:0:1.2.3.4` | `::ffff:0:102:304` | | `sceNetInetNtop` of `fe80::5efe:102:304` | `fe80::5efe:1.2.3.4` | `fe80::5efe:102:304` | | `sceNetInetPton` of `::01.2.3.4` | 1 | 0 | | `sceNetInetPton` of `::1.2.3.04` | 1 | 0 | | `sceNetInetPton` of `::ffff:01.2.3.4` | 1 | 0 | FreeBSD: - prints a dotted tail only for `::a.b.c.d` and `::ffff:a.b.c.d` ([`inet_ntop.c` L167-L170](https://github.com/freebsd/freebsd-src/blob/d106002967eff712894ab8b5337bbbff106ce5e0/lib/libc/inet/inet_ntop.c#L167-L170)); - parses a dotted tail with `inet_pton4` ([`inet_pton.c` L181-L182](https://github.com/freebsd/freebsd-src/blob/d106002967eff712894ab8b5337bbbff106ce5e0/lib/libc/inet/inet_pton.c#L181-L182)), which rejects a leading zero ([L94-L95](https://github.com/freebsd/freebsd-src/blob/d106002967eff712894ab8b5337bbbff106ce5e0/lib/libc/inet/inet_pton.c#L94-L95)). Both functions now convert with libkernel's `__inet_pton_nid_postfix` and `__inet_ntop_nid_postfix`. libSceNet's own checks stay: - null pointers give `EINVAL`, and another family gives `EAFNOSUPPORT`; - a short buffer still gives `ENOSPC` (28) through `sceNetErrnoLoc`, now taken from libkernel's errno. The `NET_ENOSPC` constant had no other use and is removed. Linux already follows these rules through glibc, so nothing changes there. No title is claimed. The new debt entry says that the rules are libkernel's and unverified on a console, as libkernel's own entry does. ### Tested Windows 11 (10.0.26300), WinLibs MinGW-w64 GCC 15.2.0 r7 (UCRT), Release, `-DBUILD_TESTING=ON`, on `main` at 0c3dc9ca2: - `guest_sce_net` checks three more round trips with `CheckAddressText`: `::ffff:0.0.0.1`, `::ffff:0:102:304` and `fe80::5efe:102:304`. Each goes from text to an address and back, with `ENOSPC` for every buffer shorter than the text. - New `CheckRejectedAddressText` checks that `sceNetInetPton` returns 0 and leaves the destination untouched for `::01.2.3.4` and `::ffff:01.2.3.4`. - With `main`'s `Export.cpp` the test aborts at the first new check, where `sceNetInetNtop` returns `::ffff:0:1`. With the change it passes 20 runs in a row. - 147 tests pass: - `guest_sce_net`, `guest_memory_pool_stats` and `guest_resolver`; - the `guest_datagram_*` and `guest_socket_host_write_*` tests; - the tests registered in `core/libs/prx/libc/CMakeLists.txt` and `core/libs/prx/libkernel/CMakeLists.txt` that build on Windows, libkernel's `guest_addresses` among them. - `tools/check_conventions.py --base origin/main` passes. - Linux: WSL2 (Ubuntu 24.04, GCC 13.3.0, Release with CI's configure flags), same commit. `guest_sce_net` passes with `main`'s `Export.cpp`, because glibc already follows these rules. With the change it passes 20 runs in a row. - Not tested: macOS, any title. ### 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] Unblocks: none - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-13 21:25:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T21:25:12Z.


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.

Pull request Conflicting files (lines on main) Same exports Same new files
#3897 docs/dev/debt/libSceNet.md L6
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6155523824 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4886#issuecomment-6155523824). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-13T21:25:12Z. --- <!-- pr-overlap --> 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**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #3897 | `docs/dev/debt/libSceNet.md` [L6](https://github.com/boykopovar/AnyPS5/blob/0df6e295c52e7cd6afa394ed35513bd252045c74/docs/dev/debt/libSceNet.md#L6) | | |
oneandonlydean commented 2026-10-14 02:36:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T02:36:43Z.


Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6159631926 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4886#issuecomment-6159631926). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T02:36:43Z. --- Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.

Pull request closed

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!4886
No description provided.