Files
AnyPS5/docs/dev/debt/changes/fix-libc-null-string-precision.md
PetreandClaude Opus 5.5 43dae20152 fix(libc): print a null %s whole whatever the precision
A PS5 (firmware 13.590.001) prints a null %s argument as the whole
"(null)" under any precision and still pads it to the width, so
"%.*s" with 0 and a null pointer gives "(null)", not an empty field.
The guest formatter cut "(null)" to the precision, as FreeBSD's
vfprintf does. It now drops the precision for a null narrow string.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 19:50:02 +01:00

1.2 KiB

libc

change [The narrow printf family]

  • The narrow printf family (libc) follows a payload process on a PS5 (firmware 13.60): each 16-bit unit of a %ls or %lc argument is encoded alone, so a surrogate pair gives two 3-byte sequences; a NaN keeps its sign and the + and space flags, and 0 pads it with spaces; argument positions above 99 work (up to 400 measured; above 65535 throw here); an unknown conversion such as %m or %k prints % and its letter, padded to the width, without taking an argument, and %C is one in the libc.prx of PPSA07923 and PPSA05916, where a %lc of 0 prints nothing whatever the width; a positional %C, and %S in swprintf, take no argument here, which was not measured. The guest's wcrtomb and locales are not used. On Linux, formats without those, a floating-point conversion or a %s precision use glibc, which prints NaN the same way. A null %s argument prints (null) whatever the precision, padded to the width, as snprintf did in a payload process on a PS5 (firmware 13.590.001): %.3s, %.0s and %.*s of 0 give (null) and %8.2s gives (null). The _s forms print an unknown conversion the same way, as the conversions entry below describes