From 5ade0c29df629aaa73d60a5b628ed24e3a4532b3 Mon Sep 17 00:00:00 2001 From: sezero Date: Tue, 31 Aug 2010 16:57:12 +0000 Subject: [PATCH] replaced all usess of vsprintf by q_vsnprintf git-svn-id: http://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@320 af15c1b1-3010-417e-b628-4374ebc0bcbd --- Quake/common.c | 2 +- Quake/console.c | 13 ++++++------- Quake/host.c | 10 +++++----- Quake/pr_exec.c | 2 +- Quake/sys_sdl_unix.c | 2 +- Quake/sys_sdl_win.c | 4 ++-- 6 files changed, 16 insertions(+), 17 deletions(-) diff --git a/Quake/common.c b/Quake/common.c index 10d78565..d1645d73 100644 --- a/Quake/common.c +++ b/Quake/common.c @@ -1298,7 +1298,7 @@ char *va (const char *format, ...) va_buf = get_va_buffer (); va_start (argptr, format); - vsprintf (va_buf, format, argptr); + q_vsnprintf (va_buf, VA_BUFFERLEN, format, argptr); va_end (argptr); return va_buf; diff --git a/Quake/console.c b/Quake/console.c index b7e9e927..1b184993 100644 --- a/Quake/console.c +++ b/Quake/console.c @@ -497,7 +497,6 @@ Handles cursor positioning, line wrapping, etc ================ */ #define MAXPRINTMSG 4096 -// FIXME: make a buffer size safe vsprintf? void Con_Printf (const char *fmt, ...) { va_list argptr; @@ -505,7 +504,7 @@ void Con_Printf (const char *fmt, ...) static qboolean inupdate; va_start (argptr,fmt); - vsprintf (msg,fmt,argptr); + q_vsnprintf (msg, sizeof(msg), fmt, argptr); va_end (argptr); // also echo to debugging console @@ -549,7 +548,7 @@ void Con_Warning (const char *fmt, ...) char msg[MAXPRINTMSG]; va_start (argptr,fmt); - vsprintf (msg,fmt,argptr); + q_vsnprintf (msg, sizeof(msg), fmt, argptr); va_end (argptr); Con_SafePrintf ("\x02Warning: "); @@ -572,7 +571,7 @@ void Con_DPrintf (const char *fmt, ...) return; // don't confuse non-developers with techie stuff... va_start (argptr,fmt); - vsprintf (msg,fmt,argptr); + q_vsnprintf (msg, sizeof(msg), fmt, argptr); va_end (argptr); Con_SafePrintf ("%s", msg); //johnfitz -- was Con_Printf @@ -593,7 +592,7 @@ void Con_DPrintf2 (const char *fmt, ...) if (developer.value >= 2) { va_start (argptr,fmt); - vsprintf (msg,fmt,argptr); + q_vsnprintf (msg, sizeof(msg), fmt, argptr); va_end (argptr); Con_Printf ("%s", msg); @@ -615,7 +614,7 @@ void Con_SafePrintf (const char *fmt, ...) int temp; va_start (argptr,fmt); - vsprintf (msg,fmt,argptr); + q_vsnprintf (msg, sizeof(msg), fmt, argptr); va_end (argptr); temp = scr_disabled_for_loading; @@ -640,7 +639,7 @@ void Con_CenterPrintf (int linewidth, const char *fmt, ...) int len, s; va_start (argptr,fmt); - vsprintf (msg,fmt,argptr); + q_vsnprintf (msg, sizeof(msg), fmt, argptr); va_end (argptr); linewidth = min (linewidth, con_linewidth); diff --git a/Quake/host.c b/Quake/host.c index 8c3b23dd..f53c3b55 100644 --- a/Quake/host.c +++ b/Quake/host.c @@ -115,7 +115,7 @@ void Host_EndGame (const char *message, ...) char string[1024]; va_start (argptr,message); - vsprintf (string,message,argptr); + q_vsnprintf (string, sizeof(string), message, argptr); va_end (argptr); Con_DPrintf ("Host_EndGame: %s\n",string); @@ -153,7 +153,7 @@ void Host_Error (const char *error, ...) SCR_EndLoadingPlaque (); // reenable screen updates va_start (argptr,error); - vsprintf (string,error,argptr); + q_vsnprintf (string, sizeof(string), error, argptr); va_end (argptr); Con_Printf ("Host_Error: %s\n",string); @@ -331,7 +331,7 @@ void SV_ClientPrintf (const char *fmt, ...) char string[1024]; va_start (argptr,fmt); - vsprintf (string, fmt,argptr); + q_vsnprintf (string, sizeof(string), fmt,argptr); va_end (argptr); MSG_WriteByte (&host_client->message, svc_print); @@ -352,7 +352,7 @@ void SV_BroadcastPrintf (const char *fmt, ...) int i; va_start (argptr,fmt); - vsprintf (string, fmt,argptr); + q_vsnprintf (string, sizeof(string), fmt, argptr); va_end (argptr); for (i=0 ; imessage, svc_stufftext); diff --git a/Quake/pr_exec.c b/Quake/pr_exec.c index 1be8e0cb..7d7feaa6 100644 --- a/Quake/pr_exec.c +++ b/Quake/pr_exec.c @@ -268,7 +268,7 @@ void PR_RunError (const char *error, ...) char string[1024]; va_start (argptr,error); - vsprintf (string,error,argptr); + q_vsnprintf (string, sizeof(string), error, argptr); va_end (argptr); PR_PrintStatement (pr_statements + pr_xstatement); diff --git a/Quake/sys_sdl_unix.c b/Quake/sys_sdl_unix.c index b4898d65..db7d37e9 100644 --- a/Quake/sys_sdl_unix.c +++ b/Quake/sys_sdl_unix.c @@ -163,7 +163,7 @@ void Sys_Error (const char *error, ...) Host_Shutdown (); va_start (argptr, error); - vsprintf (text, error, argptr); + q_vsnprintf (text, sizeof(text), error, argptr); va_end (argptr); fputs (errortxt2, stderr); diff --git a/Quake/sys_sdl_win.c b/Quake/sys_sdl_win.c index 02b570ec..3f8b1d43 100644 --- a/Quake/sys_sdl_win.c +++ b/Quake/sys_sdl_win.c @@ -175,7 +175,7 @@ void Sys_Error (const char *error, ...) DWORD dummy; va_start (argptr, error); - vsprintf (text, error, argptr); + q_vsnprintf (text, sizeof(text), error, argptr); va_end (argptr); if (isDedicated) @@ -210,7 +210,7 @@ void Sys_Printf (const char *fmt, ...) DWORD dummy; va_start (argptr,fmt); - vsprintf (text, fmt, argptr); + q_vsnprintf (text, sizeof(text), fmt, argptr); va_end (argptr); if (isDedicated)