From b1d3ddebbcce1418cf3275c5edd111eef03206a1 Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Sun, 26 Jan 2020 21:54:19 +0200 Subject: [PATCH] use vsnprint in Com_Printf functions --- src/backends/windows/system.c | 2 +- src/client/refresh/gl1/gl1_main.c | 2 +- src/client/refresh/gl3/gl3_main.c | 2 +- src/game/g_main.c | 4 ++-- src/server/sv_game.c | 8 ++++---- src/server/sv_send.c | 6 +++--- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/backends/windows/system.c b/src/backends/windows/system.c index dd356d3a..8397bfca 100644 --- a/src/backends/windows/system.c +++ b/src/backends/windows/system.c @@ -63,7 +63,7 @@ Sys_Error(char *error, ...) Qcommon_Shutdown(); va_start(argptr, error); - vsprintf(text, error, argptr); + vsnprintf(text, sizeof(text), error, argptr); va_end(argptr); fprintf(stderr, "Error: %s\n", text); diff --git a/src/client/refresh/gl1/gl1_main.c b/src/client/refresh/gl1/gl1_main.c index 967020ac..05fbd909 100644 --- a/src/client/refresh/gl1/gl1_main.c +++ b/src/client/refresh/gl1/gl1_main.c @@ -1952,7 +1952,7 @@ Sys_Error(char *error, ...) char text[4096]; // MAXPRINTMSG == 4096 va_start(argptr, error); - vsprintf(text, error, argptr); + vsnprintf(text, sizeof(text), error, argptr); va_end(argptr); ri.Sys_Error(ERR_FATAL, "%s", text); diff --git a/src/client/refresh/gl3/gl3_main.c b/src/client/refresh/gl3/gl3_main.c index 83c0eb14..1445b65d 100644 --- a/src/client/refresh/gl3/gl3_main.c +++ b/src/client/refresh/gl3/gl3_main.c @@ -1898,7 +1898,7 @@ Sys_Error(char *error, ...) char text[4096]; // MAXPRINTMSG == 4096 va_start(argptr, error); - vsprintf(text, error, argptr); + vsnprintf(text, sizeof(text), error, argptr); va_end(argptr); ri.Sys_Error(ERR_FATAL, "%s", text); diff --git a/src/game/g_main.c b/src/game/g_main.c index 4f1948b7..51b89177 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -156,7 +156,7 @@ Sys_Error(char *error, ...) char text[1024]; va_start(argptr, error); - vsprintf(text, error, argptr); + vsnprintf(text, sizeof(text), error, argptr); va_end(argptr); gi.error("%s", text); @@ -169,7 +169,7 @@ Com_Printf(char *msg, ...) char text[1024]; va_start(argptr, msg); - vsprintf(text, msg, argptr); + vsnprintf(text, sizeof(text), msg, argptr); va_end(argptr); gi.dprintf("%s", text); diff --git a/src/server/sv_game.c b/src/server/sv_game.c index 2af2bee3..97b2009f 100644 --- a/src/server/sv_game.c +++ b/src/server/sv_game.c @@ -78,7 +78,7 @@ PF_dprintf(char *fmt, ...) va_list argptr; va_start(argptr, fmt); - vsprintf(msg, fmt, argptr); + vsnprintf(msg, sizeof(msg), fmt, argptr); va_end(argptr); Com_Printf("%s", msg); @@ -107,7 +107,7 @@ PF_cprintf(edict_t *ent, int level, char *fmt, ...) } va_start(argptr, fmt); - vsprintf(msg, fmt, argptr); + vsnprintf(msg, sizeof(msg), fmt, argptr); va_end(argptr); if (ent) @@ -138,7 +138,7 @@ PF_centerprintf(edict_t *ent, char *fmt, ...) } va_start(argptr, fmt); - vsprintf(msg, fmt, argptr); + vsnprintf(msg, sizeof(msg), fmt, argptr); va_end(argptr); MSG_WriteByte(&sv.multicast, svc_centerprint); @@ -156,7 +156,7 @@ PF_error(char *fmt, ...) va_list argptr; va_start(argptr, fmt); - vsprintf(msg, fmt, argptr); + vsnprintf(msg, sizeof(msg), fmt, argptr); va_end(argptr); Com_Error(ERR_DROP, "Game Error: %s", msg); diff --git a/src/server/sv_send.c b/src/server/sv_send.c index 16a2ca34..da375077 100644 --- a/src/server/sv_send.c +++ b/src/server/sv_send.c @@ -58,7 +58,7 @@ SV_ClientPrintf(client_t *cl, int level, char *fmt, ...) } va_start(argptr, fmt); - vsprintf(string, fmt, argptr); + vsnprintf(string, sizeof(string), fmt, argptr); va_end(argptr); MSG_WriteByte(&cl->netchan.message, svc_print); @@ -78,7 +78,7 @@ SV_BroadcastPrintf(int level, char *fmt, ...) int i; va_start(argptr, fmt); - vsprintf(string, fmt, argptr); + vsnprintf(string, sizeof(string), fmt, argptr); va_end(argptr); /* echo to console */ @@ -130,7 +130,7 @@ SV_BroadcastCommand(char *fmt, ...) } va_start(argptr, fmt); - vsprintf(string, fmt, argptr); + vsnprintf(string, sizeof(string), fmt, argptr); va_end(argptr); MSG_WriteByte(&sv.multicast, svc_stufftext);