Commit Graph
79 Commits
Author SHA1 Message Date
Dean 6199b4807b Merge pull request #11947 from voidlakhan/feat/libc-getsubopt
feat(libc): implement getsubopt
2026-11-04 18:33:52 +13:00
Dean 44097d56db Merge pull request #10270 from orezraey/fix/libc-safe-strings-measured-ps5
fix(libc): bound and report the Annex K copies as measured on a PS5
2026-11-04 16:58:56 +13:00
Dean c28644bb50 Merge pull request #13186 from fogydes/fix/libc-inet-aton-null-text
fix(libc): reject null text in __inet_aton and __inet_addr
2026-11-03 06:28:38 +13:00
Dean 479ba68843 Merge pull request #11989 from JJenkx/windows/libc-bcmp-one
fix(libc): return 1 from bcmp for differing bytes, as titles' libc.prx does
2026-11-03 01:28:54 +13:00
Dean 39c8d56454 Merge pull request #11890 from voidlakhan/feat/libc-stpncpy
feat(libc): implement stpncpy
2026-11-03 01:28:00 +13:00
lakhantheboss 2702812f2c feat(libc): implement getsubopt 2026-11-02 14:15:28 +05:30
Dean Galvin 4476a4db4f Merge commit '88e804b0a7df1f1ac373a9e2f72fb378d925fdd4' into HEAD
# Conflicts:
#	docs/dev/debt/libc.md
2026-11-02 21:06:57 +13:00
fogydes 80d8314975 fix(libc): reject null text in __inet_aton and __inet_addr 2026-11-01 18:17:34 +05:30
orezraey cfa07b700e Merge branch 'fix/libc-default-constraint-handler-returns' into fix/libc-safe-strings-measured-ps5 2026-11-01 07:35:56 -03:00
Dean Galvin c08fe413f8 Merge main into feat/libc-timingsafe-bcmp
# Conflicts:
#	docs/dev/debt/libc.md
2026-11-01 21:13:14 +13:00
Oscar45397andClaude Opus 5.5 71707e631c test(libc): cover strnlen_s at its size limits
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-30 18:46:34 +01:00
lakhantheboss 126495863f feat(libc): implement timingsafe_bcmp 2026-10-30 13:20:24 +05:30
orezraeyandClaude Opus 5.5 ec13bce3d8 Merge main into fix/libc-safe-strings-measured-ps5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-30 01:57:47 -03:00
Dean 55c5ec999e Merge pull request #12465 from Oscar45397/test/libc-strlcpy
test(libc): cover strlcpy
2026-10-30 02:54:02 +13:00
Adrià 93dae51da8 Merge pull request #11871 from JJenkx/windows/libc-strtok-r-end-state
fix(libc): leave strtok_r's and wcstok's state at the terminator and a static empty string as titles' libc.prx does
2026-10-29 13:50:00 +01:00
orezraeyandClaude Opus 5.5 0bc7597aed fix(libc): report an unterminated strncat_s destination as too small like titles' libc.prx
strncat_s and wcsncat_s return ERANGE with the "buffer too small" message
when the destination has no terminator within destsz, and strncat_s leaves
the terminators out of its overlap ranges, as the PPSA31872 libc.prx code
does. strcat_s and wcscat_s keep the measured EINVAL.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-28 18:46:08 -03:00
Oscar45397andClaude Opus 5.5 a0a0e36d83 test(libc): cover strlcpy
No test called strlcpy. GuestStrings now checks it as FreeBSD's strlcpy(3)
defines it: the result is strlen(src); at most size - 1 bytes are copied
and the copy is NUL-terminated (a source that fits, one truncated to
size 4, an exact fit and size 1); size 0 leaves the destination alone;
an empty source gives an empty string. Bytes after the terminator stay
untouched.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-28 22:04:42 +01:00
Dean 6e30e673cd Merge pull request #11983 from JJenkx/windows/libc-xfrm-truncation
fix(libc): copy count units of a strxfrm or wcsxfrm result that does not fit, as titles' libc.prx does
2026-10-28 22:36:52 +13:00
JJenkxandClaude Opus 5.5 4117b0b2ca fix(libc): return 1 from bcmp for differing bytes, as titles' libc.prx does
bcmp returned memcmp's result, so differing bytes gave -1 or 1 by their
order. The libc.prx bundled with titles returns only 0 or 1: 1 whenever
the first n bytes differ, whichever argument holds the larger byte. The
test now requires 1 for both argument orders.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-27 11:15:20 -04:00
JJenkxandClaude Opus 5.5 7c7cc70f2e fix(libc): copy count units of a strxfrm or wcsxfrm result that does not fit, as titles' libc.prx does
When the transformed string does not fit, strxfrm and wcsxfrm wrote
count - 1 characters and a terminator. The libc.prx bundled with titles
copies the first count characters and writes no terminator, as a plain
copy of count units would, and copies the terminator only when the whole
result fits. Both functions now do the same; the return value, the
length of the source, is unchanged. The tests that expected the
terminated prefix expect the measured units instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-27 10:28:10 -04:00
JJenkxandClaude Opus 5.5 d96d96e28a fix(libc): keep strtok_r's and wcstok's exhausted string read-only
The empty string that the titles' libc.prx leaves in the saved pointer
when no token is left lies in a read-only PT_LOAD segment (R--) of all
eleven measured titles, for strtok_r and for wcstok, so a write through
the pointer faults there. The arrays are now const and stored as char*.
The tests compare pointers into unrelated arrays with std::less, and
the wcstok test overwrites the old terminator and resumes, as the
strtok_r test does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-27 08:11:44 -04:00
lakhantheboss 45cdab208e feat(libc): implement stpncpy 2026-10-27 17:07:39 +05:30
JJenkxandClaude Opus 5.5 b3d32c6214 fix(libc): leave strtok_r's state at the terminator and at a static empty string as titles' libc.prx does
strtok_r set the saved pointer to NULL after the last token and when no
token was left, as FreeBSD 11.4 does (#4625). The libc.prx bundled with
titles leaves it at the string's terminator after a last token that ends
the string, so a later call continues from there, and points it at a
static empty string when no token is left, so later calls keep
returning NULL. strtok, which runs strtok_r on its own state, follows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-27 06:42:29 -04:00
orezraeyandClaude Opus 5.5 ee3d2ffb81 Merge main into fix/libc-safe-strings-measured-ps5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-27 00:55:30 -03:00
iAbdulrrahman 118d36d8f2 feat(libc): implement timingsafe_memcmp 2026-10-26 19:32:58 +03:00
Dean 9c435c2812 Merge pull request #10399 from JJenkx/windows/libc-strcoll-byte-difference
fix(libc): return the byte difference from strcoll as titles' libc.prx does
2026-10-26 13:31:16 +13:00
JJenkxandClaude Opus 5.5 d58e050c8f fix(libc): return the byte difference from strcoll as titles' libc.prx does
strcoll called the host's strcmp, which returns -1, 0 or 1 on Windows.
The libc.prx bundled with eleven titles returns, in the C locale, the
difference of the unsigned bytes at the first mismatch, as its strcmp
does; strcoll now computes that.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-24 23:32:19 -04:00
orezraeyandClaude Opus 5.5 eb9f9bfcda Merge main into fix/libc-safe-strings-measured-ps5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-24 20:32:45 -03:00
Dean Galvin ab412f0c07 Merge main into test/libc-standard-strings 2026-10-25 12:08:44 +13:00
boykopovar f38d29fd08 refactor(sdk): add canonical headers for remaining libraries 2026-10-24 23:17:42 +03:00
Dean 4efc1d22ab Merge pull request #8673 from xXPBSXx/test/run-guarded-checks-on-windows
test(libc): run the sscanf_s checks of guest_strings on Windows
2026-10-24 23:41:20 +13:00
JJenkxandClaude Opus 5.5 f41f455f87 fix(libc): return only the sign from strcasecmp and strncasecmp as titles' libc.prx does
strcasecmp and strncasecmp returned the folded unsigned-byte difference,
following FreeBSD 11.4's strcasecmp.c (#3966, #9642). The libc.prx bundled
with eleven titles returns -1, 0 or 1, the sign of that difference; both
functions now do the same, and the byte-pair tests expect it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-23 16:06:06 -04:00
orezraeyandClaude Opus 5.5 c7f3a52987 fix(libc): share the measured _s checks with the wide forms and report them as a PS5 does
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-23 13:03:07 -03:00
orezraeyandClaude Opus 5.5 7b1566aaef test(libc): check the measured _s limits, errors and handler calls
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-23 12:53:34 -03:00
orezraeyandClaude Opus 5.5 898dc712da fix(libc): bound and report the byte _s copies as measured on a PS5
strcpy_s, strncpy_s, strcat_s, strncat_s, memcpy_s and memmove_s take RSIZE_MAX as 2^61 - 1, return EINVAL above it, call the constraint handler on every violation, and strcat_s returns EINVAL for an unterminated destination.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-23 12:51:55 -03:00
emirplus a998987278 fix(libc): compare destination object range with source in strncpy_s and strncat_s 2026-10-22 18:31:04 +03:00
emirplus 4561711b75 fix(libc): check overlap in strncpy_s and strncat_s 2026-10-22 18:29:37 +03:00
David 3db9e4ee05 test(libc): cover the standard string exports
guest_strings checked the bounds-checked and BSD string functions but not
the plain C ones. It now checks strcmp, strncmp and strcoll by sign,
strlen, strcpy and strcat return values, strncpy zero padding and its
unterminated truncation, strstr with an empty needle, strspn, bcmp and
bzero.
2026-10-22 14:57:02 +01:00
Dean b56cfb3817 Merge pull request #8444 from SwetabhSingh17/feat/libc-mem-utilities
feat(libc): implement memmem and memccpy
2026-10-21 13:24:46 +13:00
xXPBSXxandClaude Sonnet 5.5 62b8e0afdb test(libc): run the sscanf_s checks of guest_strings on Windows
CheckSscanfS was empty on Windows because its whole body sat under
#ifndef _WIN32. The 13 checks pass there, so they run on every host.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-20 22:41:34 +02:00
hypermistandClaude Opus 5.5 34e8cf1e14 feat(libc): implement basename_r
basename_r writes basename's result into the caller's buffer;
basename now uses it with its per-thread buffer.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RbLgECLQ2bpDM7oe2urGZK
2026-10-21 01:44:56 +13:00
Swetabh Singh f3dec86695 feat(libc): implement memmem and memccpy 2026-10-20 18:12:52 +05:30
Dean Galvin 20f75e94e0 Merge main into pr-8037
# Conflicts:
#	core/libs/tests/GuestStrings.cpp
2026-10-20 17:40:21 +13:00
xXPBSXxandClaude Sonnet 5.5 906b2527b8 fix(libc): convert the character argument of strrchr to char
strrchr passed its int argument to the host strrchr unchanged. On Windows the
host compares it with the signed char bytes of the string, so a byte of 0x80 to
0xFF passed as an unsigned value (0xE9) or a value above 255 (0x12F) was not
found, where FreeBSD converts the argument to char first.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-20 01:52:52 +02:00
Federico Marras 89b1b53176 feat(libc): implement bounded decimal parsing with strtonum 2026-10-19 20:19:08 +02:00
ShinMalphur cdd476fdfc test(libc): cover oversized secure string destinations 2026-10-19 13:11:17 +06:30
ArjenS-LA af691b717a feat(libc): implement overlap-safe bcopy 2026-10-15 11:27:49 -07:00
Adrià fffe7351ad Merge pull request #4625 from QRMOE/fix-libc-strtok-exhausted-state
fix(libc): clear exhausted strtok continuation state
2026-10-13 16:59:43 +02:00
Dean b9f194a890 Merge pull request #4455 from SibteProf/fix/libc-secure-copy-size-limits
fix(libc): reject oversized secure copy destinations
2026-10-13 07:26:35 +13:00
Dean f30e89ee7c Merge pull request #4365 from Gashrod1/fix/libc-strxfrm-truncation
fix(libc): truncate strxfrm like FreeBSD's C locale
2026-10-13 07:20:51 +13:00