mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 16:08:04 +02:00
util: fix gcc vsnprintf overflow
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>
This commit is contained in:
parent
b6b3b38434
commit
34d6ce28e3
1 changed files with 2 additions and 1 deletions
|
|
@ -42,6 +42,7 @@
|
|||
#include <stddef.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "util/macros.h" // PRINTFLIKE
|
||||
|
||||
|
|
@ -72,7 +73,7 @@ util_sprintf(char *str, const char *format, ...)
|
|||
{
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
vsnprintf(str, (size_t)-1, format, ap);
|
||||
vsnprintf(str, INT_MAX, format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue