feat(libSceLibcInternal): implement inet_netof, inet_lnaof, inet_makeaddr and inet_network #12924
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12924"
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 heditrigui on 2026-10-29T14:32:38Z.
What
Implement IPv4 network address helper functions in
libSceLibcInternal(core/libs/prx/libSceLibcInternal/Inet.cpp):inet_netof(NIDUXEIr+tUsM4) and alias__inet_netof(NID3R15U5X00nY): extract the network number in host byte order according to IPv4 class rules (Class A: top 8 bits, Class B: top 16 bits, Class C: top 24 bits).inet_lnaof(NID4y7OKpbXUDs) and alias__inet_lnaof(NIDbD39ou3sn7w): extract the local network address (host part) in host byte order according to IPv4 class rules.inet_makeaddr(NID5YaIoLorY8A) and alias__inet_makeaddr(NID9cf7QE7cmto): synthesize anin_addrstructure in network byte order from host byte order network (net) and host (host) parts.inet_network(NID-Qdf3rmtqRA) and alias__inet_network(NIDxDCABmswhcM): parse numbers-and-dots IPv4 network strings (supporting decimal, octal0..., and hexadecimal0x...notations) into host byte order network numbers. ReturnINADDR_NONE(0xffffffffu) on invalid formats, out-of-range components, ornullptr.core/libs/tests/GuestInetAddress.cpp(CheckInetAddressHelpers) covering Class A, Class B, Class C address extraction, address construction, and network string parsing across standard, hex, octal, and malformed inputs.docs/dev/debt/libSceLibcInternal.md.Tested
guest_inet_addresstest target on Linux x86-64 (CachyOS, kernel 6.17.7, GCC 15.2.0, glibc 2.42) by @blawesom (Release,BUILD_TESTING=ON): all assertions passed.python tools/check_conventions.py --base upstream/main --head HEADcleanly (0 errors).python core/libs/tests/test_public_headers.py --audit-onlycleanly (399 libraries, 26,751 exports verified; 0 errors).Checklist
Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-29T15:41:27Z.
Review: COMMENTED
Reviewed at dcdd2453ed (AI-assisted: yes). I tested the libSceLibcInternal code only. No console measurements.
What I ran (macOS arm64, clang, ASan + UBSan with no recovery)
Inet.cppandGuestInetAddress.cppbuilt standalone from this head. The only stubs were__errorand__inet_ntop, written as host shims. The test passes.I compiled FreeBSD 11.4
inet_network.c,inet_netof.c,inet_lnaof.candinet_makeaddr.cfrom8c639945a4, the revision your debt line cites, and compared them with this code:inet_networkstrings over0-9 x X a-f A-F g G . \t \n - +netof/lnaof/makeaddrtriples, includingnetvalues near the class thresholdsThere were 0 mismatches, so the parser follows the cited file exactly.
NIDs:
tools/nid_names.pynames all eight NIDs as written.Gates:
check_conventions --base upstream/mainpasses,git diff --checkis clean, andmerge-treeagainstbb04a4f1eais clean.pr_overlapshows only debt-file neighbours (#11748–#11752 at L22). No other PR touchesInet.cppor the same exports.1. A null text should throw, not return
INADDR_NONE(requested)FreeBSD's
inet_networkdereferencescpwithout checking it, so returning0xfffffffffor null is a result we made up. It also doesn't match this file:inet_atonthrows on null (Inet.cpp:22, debt line 21: "a null text, which the console dereferences, throws"). To match:Change the null row to expect the throw, and change the debt sentence "Null string returns
INADDR_NONE" to say a null text throws.2. Seven mutants survive the current rows (optional rows below kill all of them)
I made 20 single-edit mutants of the new code:
0x7f…orbit30 == 0). The differential confirms these give the same results.!digitis skipped before a '.' (".1","1..2"accepted)digit("xf"rejected)IsSpacenarrowed to space and tabThese 5 rows kill all 7. I took the expected values from the compiled FreeBSD file, and the rows pass on this head:
After adding them, all 17 non-equivalent mutants are killed.
Notes
inet_networkfollows the precedent inlibc/src/Math.cpp, so I have no objection there.net >= 2^24givingnet | host.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T16:29:54Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The final component in
inet_networkis not range-checked, so the implementation and test accept0x1234although the cited FreeBSD 11.4 implementation rejects that component as greater than0xff.What I ran
Head
8c611f7be6f824ca2710969862170edc9f9bc11f; basebb04a4f1ea0175e9e4f149f0359a764d62ff3296. The head includes the base and merges cleanly. Environment: Debian 12, GCC 12.2.0, Release build; focused test executable run via QEMU x86_64 in Haswell mode.Results
guest_inet_address_testsbuildguest_inet_address_testsvia QEMU0x1234assertion passes and exposes the behavior mismatch described below.git diff --checkExact output
Build:
Focused QEMU test:
Convention check:
Diff check emitted no output and exited 0. Hosted check output:
Negative control
0xffreturnsINADDR_NONE, as FreeBSD 11.4 does0x1234is returnedFindings
Blocking
inet_network_nid_postfixvalidatesvalue <= 0xffonly when a dot is encountered. The final component bypasses that guard, and thecount == 1branch returns it unchanged. Thusinet_network("0x1234")returns0x1234, while FreeBSD 11.4 rejects it at the per-componentval > 0xffUcheck. The new test currently encodes the divergent result as expected behavior. Please range-check the final component and change the test to expectINADDR_NONE(or provide console evidence that justifies diverging from the stated FreeBSD reference and update the debt entry).Non-blocking
None identified in this pass.
Sources
8c611f7be6f824ca2710969862170edc9f9bc11fand its test.inet_network.cat pinned commitd106002967eff712894ab8b5337bbbff106ce5e0, which rejects each parsed component greater than0xffbefore storing it.Not verified
To get this to a good state
Reject a final
inet_networkcomponent above0xffand add a regression assertion for the single-component case, or document console evidence for the differing behavior. I will rerun the same commands on the new head.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T16:33:19Z.
Review: CHANGES_REQUESTED
Re-checked — new head, changes requested
The
0x1234range issue is fixed in headdcdd2453eda246d1dadd843f33e4134965434589; the remaining blocking issue is that the PR asserts an unmeasured null-input result which diverges from its pinned FreeBSD reference and the repository’s unknown-behavior rule.What I ran
Head
dcdd2453eda246d1dadd843f33e4134965434589; basebb04a4f1ea0175e9e4f149f0359a764d62ff3296.git merge-tree --write-treecompleted cleanly and returned tree07024cc8c8f5c12c97f015fe80b7171722586cea. Environment: Debian 12, GCC 12.2.0, Release build; focused test executed through QEMU x86_64 in Haswell mode.Results
guest_inet_address_testsbuildgit diff --checkExact captured output
Build:
QEMU test:
Public header audit:
Conventions:
The diff check emitted no output and exited 0. Exact-head hosted check runs:
Negative control
nullptrreturns0xffffffffu.Findings
Blocking
inet_network_nid_postfix(nullptr)returnsINADDR_NONE, and the new test pins that result, but the PR's cited FreeBSD 11.4 implementation dereferences the input before validating it. The PS5 behavior for this case is unmeasured, andAGENTS.mdsays unknown general behavior should throw and be recorded rather than return a made-up result. Please throw for the null input and change the test, or provide console evidence for the sentinel result and update the debt entry to identify that evidence.Non-blocking
A prior reviewer’s differential and mutation report recommends adding focused rows for empty dotted components, uppercase hex, and trailing whitespace/junk. The implementation now follows the cited parser shape, and I did not independently repeat that mutation run; these cases would make future parser changes easier to check.
Sources
dcdd2453eda246d1dadd843f33e4134965434589and the focused test.inet_network.c, pinned at8c639945a44588f6cfdddfb057bb5aad88735da0, reads the input directly without a null check.AGENTS.mdat the PR head.Not verified
To get this to a good state
Resolve the unmeasured null-input behavior by throwing and updating the assertion, or provide console evidence that supports the sentinel result. I will rerun the same commands on the resulting head.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T21:37:28Z.
Review: CHANGES_REQUESTED
Re-checked — new head, changes requested
The latest update addresses the attribution and null-case comments, but this head still conflicts with current
mainand has no reported run of the changedguest_inet_addresstest.What I ran
Reviewed head
2142a6b49cffeb6a7eefe829f568210142024718(PR basebb04a4f1ea0175e9e4f149f0359a764d62ff3296) against currentmain52f212ec053f917455f2f87674ddb708dcc545d8. I inspected the latest commit, the changed source/tests/debt entry, the merge preview, and hosted checks. No local build or tests were run.Results
maindocs/dev/debt/libSceLibcInternal.mdguest_inet_addresson this headdcdd2453ed, before these parser/test changesUnedited command output
Findings
Blocking
needs rebase; the merge preview against currentmainconflicts indocs/dev/debt/libSceLibcInternal.md. Please merge currentmainand resolve that debt-entry conflict.inet_networknull handling and adds edge-case/null assertions, but the reportedguest_inet_addressrun is for the previous head. Please run the registered target on the rebased head and include its result.Non-blocking
Inet.cpp, and the new tests cover uppercase hex, malformed components, trailing whitespace/junk, and null exceptions. The debt entry now explicitly says console behavior is unverified.Not verified
I did not build locally or run
guest_inet_address. The hosted jobs currently shown are conventions and labels; I did not see a product-test job for this head.To get this to a good state
Please resolve the conflict with current
main, runguest_inet_addresson the resulting head, and post the exact command and output. I will recheck the same source and test on that head.Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-11-01T19:54:15Z.
Review: COMMENTED
Testedlists only the conventions check and the header audit. blawesom's run ofguest_inet_addressat2c9970dbe2passes; please put a run of that test at the current head in the description so it doesn't depend on a comment.No title on
mainreaches these four yet, so this will be read after title-linked PRs.