summaryrefslogtreecommitdiff
path: root/src/stdio/vsprintf.c
AgeCommit message (Collapse)AuthorLines
2026-09-08sprintf: fix one byte truncation when producing string of length INT_MAXLuca Kellermann-1/+1
(v)sprint() is supposed to return the number of bytes written to s, excluding the terminating null byte. however, when these functions return INT_MAX, only INT_MAX - 1 bytes (excluding the terminating null byte) are written. this is caused by the way vsprintf() is implemented: calling vsnprintf() with n = INT_MAX. vsnprintf() returns the number of bytes that would be written to s had n been sufficiently large excluding the terminating null byte. output bytes beyond the n-1st are discarded. to accommodate the largest strings (v)sprintf() can produce (length INT_MAX, the return value is of type int), vsnprintf() has to be called with n >= INT_MAX + 1. calling vsnprintf() with n > INT_MAX is possible since commit 11fb383275d20f5f94c00425bd888a02ecbd218e.
2012-09-06use restrict everywhere it's required by c99 and/or posix 2008Rich Felker-1/+1
to deal with the fact that the public headers may be used with pre-c99 compilers, __restrict is used in place of restrict, and defined appropriately for any supported compiler. we also avoid the form [restrict] since older versions of gcc rejected it due to a bug in the original c99 standard, and instead use the form *restrict.
2011-02-12initial check-in, version 0.5.0v0.5.0Rich Felker-0/+7