Skip to content

fix(libSceNet): follow FreeBSD inet text rules for IPv6 - #9494

Open
EagleBearerYS wants to merge 4 commits into
boykopovar:mainfrom
EagleBearerYS:fix/libscenet-inet-text-rules
Open

EagleBearerYS wants to merge 4 commits into
boykopovar:mainfrom
EagleBearerYS:fix/libscenet-inet-text-rules

Conversation

@EagleBearerYS

@EagleBearerYS EagleBearerYS commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Opened again from #4886: title-less conformance fixes of this kind are merged now, for example #7365 and #8411.

What

On Windows, sceNetInetPton and sceNetInetNtop (libSceNet/Export.cpp) convert IPv6 text with 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.

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 IPv6 text with libkernel's __inet_pton_nid_postfix and __inet_ntop_nid_postfix, on every host. IPv4 text keeps the host conversion: #7921 and #8056 gave sceNetInetPton IPv4 rules measured on a PS4 since #4886 was opened, so this PR no longer touches IPv4. libSceNet's own handling around the conversion stays as main has it:

  • null pointers give EINVAL, and another family gives EAFNOSUPPORT;
  • a failed conversion leaves the destination unchanged;
  • sceNetInetNtop still converts into its own buffer and copies the text, so a short buffer still gives ENOSPC (28) through sceNetErrnoLoc.

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

Overlap: #9231 (Gonic0) adds a macOS check of an IPv4 address's leading zeros in sceNetInetPton, before the host conversion this PR leaves IPv4 to. The two merge without a conflict in either order, and Gonic0 agreed that neither waits for the other (comment). #9506 (Noxy-HNR) changes the DNS functions in the same Export.cpp and other lines of libSceNet's debt file; it merges cleanly with this PR, and no order is needed.

Tested

On GitHub's runners from my fork, merged with main at a6dcea9 (run):

  • 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.
  • Windows: with main's Export.cpp guest_sce_net fails. With the change it passes 10 runs in a row, with main's IPv4 whitespace and sceNetInetPtonEx checks.
  • Linux: guest_sce_net passes with main's code, because glibc already follows these rules, and 10 runs in a row with the change.
  • On both, every test registered under core/libs/prx/libc and core/libs/prx/libkernel passes: 115 and 197 on Linux, 142 and 207 on Windows.
  • After the merge with main at 4a17c71 (094e920, no conflicts, the PR's own diff unchanged; run): guest_sce_net fails on Windows with main's Export.cpp and passes 10 runs in a row with the change; on Linux it passes both ways. The libc and libkernel suites pass on both (116 and 197 on Linux, 143 and 207 on Windows).
  • tools/check_conventions.py --base origin/main passes.
  • Not tested: macOS, a console, any title.

Checklist

sceNetInetPton and sceNetInetNtop called Winsock's InetPtonA and
InetNtopA on Windows. Those print IPv4-translated and ISATAP addresses
with a dotted tail, print ::ffff:0.0.0.1 as ::ffff:0:1, and accept a
leading zero in a dotted tail, where FreeBSD does neither. Both now
convert with libkernel's inet_pton and inet_ntop, which follow the
FreeBSD 11.4 rules since boykopovar#3530.
boykopovar#5124 adds an entry after sceNetShowNetstat at the end of the unknown function info list, so adding the inet entry there made the two pull requests conflict.
@EagleBearerYS EagleBearerYS changed the title fix(libSceNet): follow FreeBSD inet text rules fix(libSceNet): follow FreeBSD inet text rules for IPv6 Oct 21, 2026

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the IPv6 conversion routing and regression coverage. The change delegates only IPv6 text conversion to libkernel’s FreeBSD-compatible helpers, leaves IPv4 conversion untouched, and retains libSceNet’s surrounding error and destination-buffer behavior. The tests cover mapped and embedded IPv4 forms, rejection of dotted octets with leading zeroes, and destination preservation. The reported Linux and Windows guest suites pass; conventions, intake, eligibility, labels and report checks pass, while hosted product builds are skipped.

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

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 6879 core/libs/prx/libSceNet/Export.cpp
PR 7201 core/libs/prx/libSceNet/Export.cpp
PR 8254 core/libs/prx/libSceNet/Export.cpp
docs/dev/debt/libSceNet.md
PR 8658 core/libs/prx/libSceNet/Export.cpp
PR 9060 core/libs/prx/libSceNet/Export.cpp
core/libs/tests/GuestSceNet.cpp
docs/dev/debt/libSceNet.md

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed the current head and manually checked the shared-file warnings. The open PRs listed there change adjacent socket functions, other exports, or unrelated test cases; none overlaps the IPv6 text-conversion implementation or its assertions. The conversion change remains limited to IPv6 and uses libkernel's FreeBSD-compatible helpers; IPv4 host conversion and libSceNet's error handling remain intact. The reported Windows and Linux guest suites cover the changed behavior. Hosted policy checks pass; product and relinker jobs are skipped. No local tests were run.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The IPv6 conversion change remains narrowly scoped and the reported tests cover the changed Windows behavior, invalid dotted-tail leading zeroes and output preservation; IPv4 conversion and the surrounding error contract stay intact. I manually checked the uncomparable export warnings at a high level, but the live overlap table now includes #9506 touching Export.cpp and the same debt file. Its DNS implementation and this PR’s IPv6 conversion are distinct behavior, but the shared export/debt hunks need a current combined-base check and both registrations/entries must survive. The PR is based on a6dcea9 while current upstream main is ab347d1. Please rebase, coordinate/record any needed merge order with #9506, and rerun the focused guest_sce_net test and conventions/overlap checks on current main. Hosted product jobs are skipped; I did not run local tests.

@EagleBearerYS

Copy link
Copy Markdown
Contributor Author

Thanks, @MarcZX10. The branch now has main at 4a17c71 merged in (094e920), with the PR's own diff unchanged. On GitHub's runners (run) guest_sce_net passes 10 runs in a row on both and fails on Windows with main's code; the libc and libkernel suites pass on both, and conventions pass. Tested now says so. #9506 merges cleanly with this PR: its DNS changes and debt lines don't meet this PR's, so no order is needed, and Overlap and Depends on now say so.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants