libc: narrow snprintf on Windows crashes or misreports on a width or precision beyond int #11292
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 oneandonlydean on 2026-10-26T00:25:12Z.
On Windows the narrow
snprintffamily goes throughLibcDetail::FormatWindows, and a very large width or precision crashes or returns the wrong result, where Linux fails with -1 and errno 75. I haven't reproduced this; the results are from wachi35676's Windows 11 run (WinLibs GCC 15.2.0, Release) while testing #10813: https://github.com/boykopovar/AnyPS5/pull/10813#issuecomment-6405125956.With
snprintf_nid_postfix(buf, 16, fmt, 1):%99999999999dand%.99999999999dend in 0xc00000fd (stack overflow)%4294967296sends in 0xc0000005%.4294967296sreturns 0%2147483648dreturns 1 with errno 0%2147483647dand%2147483646dend in 0xc00000fd, where Linux returns 2147483647 and 2147483646#10813 covers the same class for the wide family; this is the narrow counterpart. #3975 and #5293 are about unknown conversions aborting, which is a different failure. A fix needs bounded, instrumented tests rather than giant buffers.