fix(libc): set EOVERFLOW when vswprintf truncates or the size exceeds INT_MAX #4833
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4833"
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 Gashrod1 on 2026-10-12T23:09:02Z.
What
vswprintf_nid_postfix(andswprintf, which goes through it) returned -1 on truncation without setting errno, and accepted sizes aboveINT_MAX + 1. FreeBSD sets EOVERFLOW in both cases (lib/libc/stdio/vswprintf.c, same in stable/11):if (n - 1 > INT_MAX) { errno = EOVERFLOW; *s = L'\0'; return (-1); }before formatting, andif (nwc == n) { s[n - 1] = L'\0'; errno = EOVERFLOW; return (-1); }when the output does not fit.Both now set errno 84. The truncated text and its terminator were already the same as FreeBSD's and are unchanged; a size above
INT_MAX + 1now writes only the terminator and returns -1 before formatting.guest_wide_formattingchecks errno for a truncated result, for a result whose terminator does not fit and for a size ofINT_MAX + 2. It fails onmainand passes with the change.Tested
Linux (Arch, GCC), Release,
BUILD_TESTING=ON, based onmain43e3a70f8:guest_wide_formattingaborts onmainand passes with the change (3 runs); full build and fullctestpass. Windows (WinLibs MinGW-w64 GCC 15.2.0 r7, NVIDIA RTX 5060), Release,BUILD_TESTING=ON: full build and fullctestpass (1019 tests, the same 7 skipped as onmain). No title or homebrew run.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T02:37:01Z.
Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.
Pull request closed