fix(libc): stop wcstombs before multibyte character exceeding capacity #21244
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/21244"
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 gurtgg on 2026-11-16T01:31:27Z.
What
Forward
wcstombs_nid_postfixdirectly towcsrtombs_nid_postfix(destination, &source, capacity, nullptr)inWideConversion.cpp. Previously,wcstombs_nid_postfixperformed a manual byte-by-byte copy without verifying that multi-byte UTF-8 sequences fit completely in the remaining destination capacity, causing partial leading UTF-8 bytes to be written when a 2-byte or 3-byte wide character exceeded the remaining buffer space. Removing the unused<climits>header cleans up the include list.Extend
GuestWcsrtombs.cppunit tests to verifywcstombs_nid_postfix: full ASCII conversion with null terminator, errno preservation, zero-capacity destination buffer handling, exact-capacity truncation without null terminator, null destination length queries on ASCII and multi-byte strings, 2-byte and 3-byte UTF-8 character conversion, and clean stoppage before multi-byte characters that exceed remaining capacity without writing partial lead bytes.Tested
GuestWcsrtombs.cppcovering ASCII, zero capacity, exact capacity, length query, 2-byte UTF-8 (U+0100), 3-byte UTF-8 (U+20AC), and partial multi-byte character boundary stoppage.Checklist
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-16T01:40:45Z.
Review: CHANGES_REQUESTED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
2016c41142:tools/check_conventions.pypassed;git diff --checkreported whitespace errors.guest_wcsrtombs_testsbuilt cleanly.guest_wcsrtombs):Requesting changes for the points above.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-16T02:11:45Z.
Review: APPROVED
Reviewed — looks good
The reviewed change at
2016c411424a4833787b37a1f0b945129b006b7edelegateswcstombsto the existing conversion routine, which stops before a multibyte character that does not fit; no verified blocking defect was found.What I ran
No build or tests were run. I read the prepared description, commit list, manifest, diff, and both changed files, plus the implementation of
wcsrtombs_nid_postfixused by the change.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Build and unit test execution were not performed. Author-reported prechecks and their outputs were not independently verified. No files were excluded by the prepared manifest; both changed files were read.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-16T04:00:49Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
6fd6699ad3:tools/check_conventions.pypassed;git diff --checkclean.guest_wcsrtombs_testsbuilt cleanly.guest_wcsrtombs):core/libs/prx/libc/src/WideConversion.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 MarcZX10 on 2026-11-16T05:01:59Z.
Review: APPROVED
Reviewed — looks good
The change at head
6fd6699ad3c4f5194a11f135251764ed7df74984routeswcstombs_nid_postfixthrough the existing whole-character conversion and adds coverage for capacity boundaries; no blocking defect is apparent in the changed code.What I ran
Read the prepared description, commit summary, manifest, diff, both changed files, and the existing
wcsrtombs_nid_postfiximplementation inMultibyte.cpp. I did not run tests or other commands.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Tests were not run. No excluded files were listed in the available manifest;
files.jsonwas not available through the reader. No other repository files were read.To get this to a good state
Nothing is required.