Anything higher than INT_MAX results in overflow although the parameter is declared as size_t.
Worse, with (size_t)-1 it is silently ignored and Woverflow is not emitted.
Closes #4226
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Tested-by: Prodea Alexandru-Liviu <liviuprodea@yahoo.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9134>
#include <stddef.h>
#include <stdarg.h>
#include <string.h>
+#include <limits.h>
#include "util/macros.h" // PRINTFLIKE
{
va_list ap;
va_start(ap, format);
- vsnprintf(str, (size_t)-1, format, ap);
+ vsnprintf(str, INT_MAX, format, ap);
va_end(ap);
}