fix(libSceIcu): read resource 0 as the empty string in the UTF-8 resource accessors #25371
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/25371"
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 kessler-drift on 2026-11-22T00:15:51Z.
What
ures_getUTF8String,ures_getUTF8StringByIndexandures_getUTF8StringByKeyread every type-0 resource atpRoot + offset * 4, including the resource word 0. ICU stores an empty string as that word, andres_getStringmaps it to a static empty string instead of reading the bundle (ICU 68.2uresdata.cppl.335-338:res==0 ? &gEmptyString.length : pResData->pRoot+res; ICU 78.1 has the same lines).genrb68.2 writesb { "" }as resource 0 from format version 2 on.The accessors took
pRoot[0], the root resource of the bundle, as the string length: with a root table such as0x20000040they tried to copy 2^29 UTF-16 units past the end of the bundle and threwNotImplemented, and with a smallpRoot[0]they returned bytes of the bundle. They now return the empty string for resource 0, as ICU does, through the existing empty-string path (""withoutforceCopy, a terminateddestwith it). The debt entry of these accessors does not mention this case and is unchanged.Tested
Ubuntu 26.04 x86-64 container under Rosetta on macOS 27.2, GCC 15.2,
main15826135019. A harness compiles one resource file withgenrb68.2 in format versions 1 and 2, opens it with ICU 68.2 (ures_openDirect), copies the 200 bytes of each realUResourceBundle(the root, every item, nested items), and calls the three accessors on each object with ICU 68.2 and with this module (same bytes,pRootpointed at the module's copy of the same.resfile): every index or key,pLengthnull, capacities -1 to 4, 13, 37, 38, 109 and 150,forceCopy0 and 1, incoming status 0, -124, -128 and 1, each call in a forked process.mainThe 18 remaining calls differ only by an incoming
U_STRING_NOT_TERMINATED_WARNINGthat ICU clears when it terminates the output, which these accessors do not do for any string; that is a separate change. No other result changed. Two more resource files, generated at random from seeds 20261121 and 20261122 (36 288 and 18 900 calls), give the same picture: 583 and 318 results change, 484 and 264 of them now equal ICU 68.2, the others differ only by that incoming warning, and no other result changes.guest_icu_resource_utf8now puts a one-unit string atpRoot[0]and reads resource 0 through all three accessors (a bundle whose resource is 0, with and withoutforceCopy, and a table whose item is 0, by index and by key); it fails without the change. The 87libSceIcutests and the 91public_headers, registration and progress tests pass, apart from the failuresmainalready has under Rosetta.Not tested on a console, on Windows or on macOS.
python3 tools/check_conventions.py --base upstream/mainpasses.python3 tools/pr_overlap.py --namesfor the three accessors lists no open pull request that changesResourceUtf8.cpp; #24322, #24910 and #24917 split libraries, #14443, #19670 and #24288 change other resource files.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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-22T00:17:01Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
7fe662cb3d:tools/check_conventions.pypassed.guest_icu_resource_utf8_testsbuilt cleanly.guest_icu_resource_utf8):core/libs/prx/libSceIcu/ResourceUtf8.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by throny on 2026-11-22T02:12:30Z.
Review: APPROVED
Review: ✅ correct
Basis: code read against the pinned ICU (
3rdparty/icu)Checked
res_getStringNoTraceusesres==0 ? &gEmptyString.length : pResData->pRoot+res(uresdata.cpp:336), andures_getUTF8Stringreaches it throughures_getString.RES_BOGUSis0xffffffff, never 0.main,ReadStringread a length frompRoot[0], the root resource word, so an empty-string resource came back as garbage or a failed copy. All three exports (ures_getUTF8String,ByIndex,ByKey) go throughReadString, so the one guard covers them.pool[0]=1,'z'makes the test fail onmain.Findings: none.
Suggested action: merge.
AI-assisted review (Claude Code) · head
7fe662cb3d· basemain851212fb98Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T05:37:15Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the reviewed code and reported checks support merging.
What I ran
Reviewed head
7fe662cb3d4b7c8b7cbc58a8020c7288db93a5ca. No commands or tests were run in this review. Readdescription.md,commits.md,manifest.json,diff.patch, and both changed files at the pinned head:core/libs/prx/libSceIcu/ResourceUtf8.cppandcore/libs/prx/libSceIcu/tests/ResourceUtf8.cpp.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Did not run the reported tests, harness, or convention check; their results are author-reported. Console, Windows, and macOS behavior were not tested. No files were excluded from review;
files.jsonwas unavailable, butmanifest.jsonlists both changed files as included and both were read.To get this to a good state
Nothing is required.