feat(libSceNpCommon): implement sceNpUtilParseJid and sceNpUtilJidToNpId #12825
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12825"
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 hypermoist on 2026-10-29T11:42:17Z.
What
Implements
sceNpUtilParseJidandsceNpUtilJidToNpIdin place of theirNotImplementedstubs. The signatures and behaviour are read fromlibSceNpCommon.sprxof firmware 13.60 (disassembly, not measured on a console).NpJidis the 32-byte structure the parser fills: user, domain and resource pointers plus a reserved word.sceNpUtilParseJid(NpJid* jid, const char* text, char* buffer, size_t bufferSize, size_t* required)0x80550601for a nulltext, or for nojid/bufferpair and norequired.jidand abuffer, it clears thejidfirst. Otherwise it only measures.0x80550604.[A-Za-z0-9+._-]+followed by@. Without that@the user is empty and the text is a domain.@, the domain is[A-Za-z0-9._-]+with trailing dots trimmed./or a space), and keeps the rest unchecked as the resource. Soa@b./resgives resource/res, anda@b cgives resourcec.bufferand thejidpoints at the copies.*requiredis the total size.0x80550602and clears thejidagain.sceNpUtilJidToNpId(NpIdFull* npId, const NpJid* jid)0x80550601for a null pointer.0x80550604unless the user is 1 to 16 bytes, the domain isXX.YY.<label>.playstation.net(the four characters letters or digits, the label possibly empty) and the resource is at most 4 bytes.opt, andreserved[0] = 1.The debt file replaces the two "signature unknown" entries with one entry that states the source, the quirks, and that
0x80550604has no name in any source. It also removessceNpUtilJidToNpIdfrom the entry that says it throws because it depends on network domain names.Tested
Linux (CachyOS, GCC, Release):
ctest --test-dir build -R 'np_common|public_headers' --output-on-failure, 70/70 passed.TestJidinGuestNpCommonRuntime.cppcovers:Comparison against the firmware code: I relinked the 13.60 module with this repo's relinker and ran both functions under unicorn (x86-64 emulation on a PC, not a console). The module's
strlen,strncmp,memcpy,memsetand_Getpctypeimports were bound to C-locale implementations.jidpointer points, the reserved word and*required.Windows not built. Not run on a console.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Strings.cpp, like #12818; the two merge cleanly in either order)Assisted With AI: Yes. All tests were run locally on computer hardware (AMD Ryzen 5 5600G, 32 GB RAM, NVIDIA GeForce RTX 3060, CachyOS Linux 7.3, GCC 16.2), not on an actual console.
🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-29T11:56:37Z.
Review: COMMENTED
Reviewed on macOS arm64 (Apple clang, ASan + UBSan,
-fno-sanitize-recover=all) at9b48ab5214, as a standalone build oflibSceNpCommon/Strings.cppandTestJid. I didn't run the full CMake lane.Result:
TestJidpasses, with no sanitizer reports.check_conventions --head,git diff --checkandgit merge-treeagainst mainba5b5330b3are clean. It also merges cleanly with #12818.pr_overlap(1406 PRs probed) only reports #12829 and #12830. Both are stacked on this commit and declareDepends on, and both merge cleanly with it.Mutation check: I applied 25 single-line mutants to
SplitJid,sceNpUtilParseJidandsceNpUtilJidToNpId.user != 0gives the same empty user.*jid = {}on a too-small buffer changes nothing, because the jid is cleared at entry and its fields are only assigned after the loop.TestJid:-removed from the user bytes._removed from the domain bytes.+added to the domain bytes.whileturned into anif, so only one dot is trimmed.*jidremoved. A blank text then returns0x80550604with the caller's old pointers left in place.find_first_not_of(" \t"), so tabs would also be skipped.IsAsciiAlnum(domain[3])not checked.strcmpturned intostrncmp(..., 15), so.playstation.networkwould be accepted.These rows go into
TestJidbefore thenullptrtext row:These rows go before the null-pointer conversion row:
With all of them added, the head passes, all 8 survivors are killed, and only the 2 equivalent mutants remain.
I derived every expectation from what the PR states: C-locale classes, one skipped character after the domain, the exact suffix, and the clear at entry. I couldn't check them against the module myself. Please run them through your unicorn differential before adding them. The tab row in particular rests on "leading spaces" meaning only
' '.Nit: this is the same one as on #12818. "all test done locally on actual hardware" contradicts "Not run on a console" a few lines above. The differential ran under unicorn on a PC.
Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-29T12:36:49Z.
Review: APPROVED
Re-reviewed at
36cf6fb45fon macOS arm64 (Apple clang, ASan + UBSan,-fno-sanitize-recover=all), using the same standalone build as before:Strings.cppplusTestJidand its helpers, taken verbatim from the PR.Result:
TestJidpasses with no sanitizer reports. The new commit only adds the suggested rows to the test (15+/1-,GuestNpCommonRuntime.cpp).check_conventions --head,git diff --checkandgit merge-treeagainst main5454cd2e45are clean.Mutation check: I re-applied the 8 mutants that survived last time. All 8 are now killed, each by the row written for it:
-removed from user bytes_removed from domain bytes+added to domain byteswhile→if*jidremovedfind_first_not_of(" \t")domain[3]check droppedstrcmp→strncmp(..., 15)Thanks for running the rows through the 13.60 differential first. The tab row now rests on a firmware result, not just my reading of the body. The body nit is also resolved.
Cosmetic nit (optional): the rewrapped conversion line lost a space:
NpUtilInvalid &&sceNpUtilJidToNpId(&npId, nullptr).Approving.