Files
AnyPS5/docs/dev
JJenkxandClaude Opus 5.5 ea6aa0a809 fix(libc): follow the console fgetws for short buffers and read errors
The fgetws in the libc.prx that titles ship (the same 133 bytes in the
copies of PPSA13934, PPSA07923 and PPSA05916, read from disassembly)
differs from this one in two cases:

- A size below 2 returns null at once, without writing the buffer,
  errno or the stream (cmp $0x2,%esi; jge, else the null result). Here a
  size of 1 stored a NUL and returned the buffer, and a size of 0 or less
  set the stream error and errno 22.
- When fgetwc returns -1 after characters were stored, the console
  null-terminates and returns the buffer; it returns null only when
  nothing was stored, and never checks ferror. Here a read error after
  some characters returned null.

The rest already matches: each fgetwc result is stored as its low 16 bits
(mov %ax,(%rbx)), and the newline test compares all 32 bits. A null buffer
or stream, which the console dereferences, keeps failing with errno 22.

guest_standard_streams now expects the console results for sizes 1, 0
and -1 and for an invalid byte after a stored character; its fgetwc error
indicator check is unchanged. The libc debt entry cites the reading and
what it leaves unverified.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-22 16:19:24 -04:00
..