If vsnprintf fails with errno EOVERFLOW, the results are very platform
dependent but never useful. The implementation in glibc fills bytes with
blanks, FreeBSD fills them with zeros, OpenBSD and Windows set first
byte to '\0'.
Just stop processing and don't print anything, which makes it follow
the OpenBSD and Windows approach.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
length = vsnprintf(fmtbuff, fmtbuff_length, fmt, ap);
va_end(ap);
+ /* If vsnprintf will always fail, stop early. */
+ if (length < 0 && errno == EOVERFLOW)
+ return;
+
/* If the result was too large, allocate a buffer on the heap. */
while (length < 0 || (size_t)length >= fmtbuff_length) {
if (length >= 0 && (size_t)length >= fmtbuff_length)