test(libc): cover wcsncat_s exact fit, one too many and unterminated destination #8269
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8269"
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 thuanquang on 2026-10-20T07:55:40Z.
What
A follow-up @oneandonlydean listed on #6144 (comment): the
guest_wide_stringstest does not cover thesewcsncat_scases. This adds them; no code changes.abcin an 8-unit buffer succeeds with1234(7 units and the terminator), and12345givesERANGE(34) withdest[0]cleared.ERANGEwithdest[0]cleared.@oneandonlydean compared the cases with the console's own
wcsncat_sinlibc.prx(read from the module a retail title ships, not run on a console): these three match it. The first head also had an overlapping-source row (dest + 1appended toabcwithcount2, expectingEINVAL). The console copies that call and returns 0, because it rejects only when the written range[dest + len1, dest + len1 + len2)meets the read range[src, src + len2), so the row would have pinned a false positive inmain's check. It is dropped; aligningmain's check with the console is a separate change.The rows sit after the existing
wcsncat_srows, away from #7952'swcscpy_srows.Tested
Windows 11 26200, WinLibs GCC 15.2.0 r7, Release,
BUILD_TESTING=ON.guest_wide_stringspasses 3 of 3 onmain47fa6eecfwith this head (a936eadd6); the first head passed 3 of 3 onmain1edbe4b5e.wcsncat_s's length check off by one (length > destsz - used), the test aborts on the exact-fitrequire. None of the existing rows appends exactly up todestsz - 1.python tools/check_conventions.py --base origin/mainwith this title and body passes.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 github-actions[bot] on 2026-10-20T08:08:18Z.
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/tests/GuestWideStrings.cppImported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T18:16:49Z.
Thanks. I compared these cases with the console's own
wcsncat_sinlibc.prx, read from the module that a retail title (PPSA21564) ships. Three of the four new lines match it, but the overlap case doesn't:"abc"+"1234"in 8): the console returns 0. Matches."abc"+"12345"in 8) and unterminated destination (4 ×'x'in 4): the console computeswcsnlen(dest, destsz) + wcsnlen(src, count), and when that is>= destszit setsdest[0] = 0and returns 34 (ERANGE). Both match."abc",src = strBuf + 1,count = 2): the console rejects a copy only when the bytes it writes,[dest + len1, dest + len1 + len2), intersect the bytes it reads,[src, src + len2). Here it writes indices 3-4 and reads 1-2, so they don't intersect. The console copies, returns 0 and leaves"abcbc". Main's check compares the raw distance with(length + 1) * 2, so it reports 22 for this call, and the new line would pin that false positive.Suggested shape: drop the overlap line, or (better) align main's check with the console and test both sides of it, e.g. the call above returns 0 with
"abcbc", whileu"abc\0xyz"withsrc = strBuf + 4,count = 3(the read range starts inside the write range) returns 22 withdest[0] == 0.This comes from reading the module, not from running on a console.
Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-21T12:15:15Z.
@oneandonlydean thanks for checking these against the console's
libc.prx, and sorry this went unanswered. I took the first option here:a936eadd6drops the overlap row, so the test no longer pinsmain's false positive, and the three rows you confirmed stay.guest_wide_stringspasses 3 of 3 onmain47fa6eecfwith this head. Aligningmain's check with the console (reject only when[dest + len1, dest + len1 + len2)intersects[src, src + len2), with both of your cases as tests) is a separate fix, and I'll open it as its own PR.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-21T12:25:34Z.
@thuanquang thanks, no problem. Checked on
a936eadd6: it removes only the overlap row (and the reset after it), and the three console-confirmed rows stay. With that, the test pins only what the console does. A separate PR formain's overlap check sounds right. This one is ready for CI on our side.