feat(libc): implement safe wide string and concatenation functions #6144
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6144"
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 freshstart2066-create on 2026-10-14T23:21:36Z.
What
Onimusha: Way of the Sword (
PPSA27836, #5595) and other RE Engine titles import wide string and memory functions fromlibcduring early startup and initialization. When loading without these exports, dynamic module resolution fails with:This PR implements the missing wide string copy, concatenation, and memory operations:
wcsncpy_s(Slmz4HMpNGs)wcsncat(pA9N3VIgEZ4)wcsncat_s(VxG0990tP3E)wcscat_s(MqeMaVUiyU8)wmemcpy_s(BTsuaJ6FxKM)wmemmove_s(F8b+Wb-YQVs)Implementation Details
destandsrcpointers (GuestEinval = 22).destsz <= (SIZE_MAX >> 1) / sizeof(char16_t)(GuestErange = 34).destis non-null anddestszis valid.wmemcpy_s,wcsncpy_s, andwcsncat_s.wcsncat(pA9N3VIgEZ4) appending at mostnwide characters fromsrcto null-terminateddestwith null-termination.docs/dev/debt/libc.md.core/libs/tests/GuestWideStrings.cpp(guest_wide_strings), testing parameter validation, out-of-range bounds, overlap rejection, null-termination, and concatenation semantics.Tested
core/libs/tests/GuestWideStrings.cppcover all new functions and edge cases.git merge-tree upstream/main feat/libc-safe-wide-stringspasses cleanly with zero conflicts (tree:d7fc793fe8f7dbdfb82570bee84fe88323b6d4c3).python tools/check_conventions.py --base 584cc4c57:All conventions checks passed.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)Co-authored-by: Nawasfadili [email protected]
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T23:22:21Z.
Progress report (
2559e96→c33036b)📈 System libraries: 88.73% (+0.02%, +6 implemented functions)
✅ 6 implemented
wcscat_s_nid_postfixwcsncat_nid_postfixwcsncat_s_nid_postfixwcsncpy_s_nid_postfixwmemcpy_s_nid_postfixwmemmove_s_nid_postfixImported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:15:27Z.
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.
core/libs/prx/libc/src/Strings.cppdocs/dev/debt/libc.mddocs/dev/debt/libc.mdcore/libs/tests/GuestWideStrings.cppdocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mdcore/libs/prx/libc/src/Strings.cppdocs/dev/debt/libc.mdcore/libs/prx/libc/src/Strings.cppcore/libs/prx/libc/src/Strings.cppdocs/dev/debt/libc.mdImported from boykopovar/AnyPS5. Originally posted by coltken95 on 2026-10-15T21:03:13Z.
Tested on Linux x86-64 (Release build), with
c33036b16merged into main4eb91eacd:guest_wide_stringspasses.libc/src/Strings.cpp:guest_wide_string_testsdoesn't link (undefined reference to 'wcscat_s_nid_postfix','wcsncat_nid_postfix','wcsncat_s_nid_postfix','wcsncpy_s_nid_postfix','wmemcpy_s_nid_postfix').AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T23:54:43Z.
Checked the six Annex K / wide functions against C11 K.3.7 (null, RSIZE_MAX, overlap, count vs destsz, destination zeroing on violation): they match, the debt line records the unverified console RSIZE_MAX/error values.
guest_wide_stringspasses on the PR merged onto main and fails to link without the change; no other open PR adds these functions. Merging.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-18T01:16:10Z.
@adriadam10 you wrote "Merging." on the 16th, but it didn't go through. The head is unchanged since your review (
c33036b16), full CI is green on it (guest_wide_strings passes on Linux and Windows) and it merges cleanly with main. Do you want to merge it yourself, or are you happy for us to merge it?One optional follow-up, not a blocker: the tests don't yet cover three
wcsncat_scases (exact fit, an unterminated dest, an overlapping src). The code handles all three correctly.