fix: multiple additional buffer overruns

found by Zwip-Zwap_Zapony
This commit is contained in:
K J 2025-08-13 14:11:13 -04:00 committed by NepDisk
parent 421099f68e
commit 74e6a93193
3 changed files with 5 additions and 5 deletions

View file

@ -1281,7 +1281,7 @@ void CONS_Alert(alerttype_t level, const char *fmt, ...)
txt = malloc(8192);
va_start(argptr, fmt);
vsprintf(txt, fmt, argptr);
vsnprintf(txt, 8192, fmt, argptr);
va_end(argptr);
switch (level)
@ -1317,7 +1317,7 @@ void CONS_Debug(UINT32 debugflags, const char *fmt, ...)
txt = malloc(8192);
va_start(argptr, fmt);
vsprintf(txt, fmt, argptr);
vsnprintf(txt, 8192, fmt, argptr);
va_end(argptr);
// Again I am lazy, oh well

View file

@ -2027,7 +2027,7 @@ void I_Error(const char *error, ...)
if (errorcount > 20)
{
va_start(argptr, error);
vsprintf(buffer, error, argptr);
vsnprintf(buffer, 8192, error, argptr);
va_end(argptr);
// Implement message box with SDL_ShowSimpleMessageBox,
// which should fail gracefully if it can't put a message box up
@ -2052,7 +2052,7 @@ void I_Error(const char *error, ...)
// Display error message in the console before we start shutting it down
va_start(argptr, error);
vsprintf(buffer, error, argptr);
vsnprintf(buffer, 8192, error, argptr);
va_end(argptr);
I_OutputMsg("\nI_Error(): %s\n", buffer);
// ---

View file

@ -181,7 +181,7 @@ static VOID FPrintf(HANDLE fileHandle, LPCSTR lpFmt, ...)
DWORD bytesWritten;
va_start(arglist, lpFmt);
vsprintf(str, lpFmt, arglist);
vsnprintf(str, 1999, lpFmt, arglist);
va_end(arglist);
WriteFile(fileHandle, str, (DWORD)strlen(str), &bytesWritten, NULL);