From 29970187d7025664965b9189e7a3a9803c03efe7 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Tue, 5 Dec 2000 16:51:01 +0000 Subject: [PATCH] sprintf audit. --- source/console.c | 3 ++- source/gl_screen.c | 2 +- source/model_brush.c | 2 +- source/quakeio.c | 2 +- source/r_part.c | 2 +- source/screen.c | 2 +- source/sv_main.c | 2 +- 7 files changed, 8 insertions(+), 7 deletions(-) diff --git a/source/console.c b/source/console.c index 1cc9754..11cf67a 100644 --- a/source/console.c +++ b/source/console.c @@ -640,7 +640,8 @@ void Con_DrawConsole (int lines) dlbar[i++] = '\x82'; dlbar[i] = 0; - sprintf(dlbar + strlen(dlbar), " %02d%%", cls.downloadpercent); + snprintf(dlbar + strlen(dlbar), sizeof (dlbar) - strlen (dlbar), + " %02d%%", cls.downloadpercent); // draw it y = con_vislines-22 + 8; diff --git a/source/gl_screen.c b/source/gl_screen.c index 28bc287..fbfeeda 100644 --- a/source/gl_screen.c +++ b/source/gl_screen.c @@ -473,7 +473,7 @@ void SCR_DrawFPS (void) fps_count = 0; lastframetime = t; } - /* Misty: I really do need to read about sprintf a bit. This thing keeps chewing on my foot! */ + /* Misty: I really do need to read about snprintf a bit. This thing keeps chewing on my foot! */ snprintf(st, sizeof(st), "%-3d FPS", lastfps); /* Misty: New trick! (for me) the ? makes this work like a if then else - IE: if cl_hudswap->int_val is not null, do first case, else (else is a : here) do second case. diff --git a/source/model_brush.c b/source/model_brush.c index 2b70f19..441fad3 100644 --- a/source/model_brush.c +++ b/source/model_brush.c @@ -699,7 +699,7 @@ void Mod_LoadLeafs (lump_t *l) loadmodel->leafs = out; loadmodel->numleafs = count; - //sprintf(s, "maps/%s.bsp", Info_ValueForKey(cl.serverinfo,"map")); + //snprintf(s, sizeof (s), "maps/%s.bsp", Info_ValueForKey(cl.serverinfo,"map")); if (!strncmp("maps/", loadmodel->name,5)) isnotmap = false; for ( i=0 ; i0) ret=gzwrite(file, buf, (unsigned)ret); } diff --git a/source/r_part.c b/source/r_part.c index cd7e25a..f07cfcb 100644 --- a/source/r_part.c +++ b/source/r_part.c @@ -110,7 +110,7 @@ void R_ReadPointFile_f (void) particle_t *p; char name[MAX_OSPATH]; -// FIXME sprintf (name,"maps/%s.pts", sv.name); +// FIXME snprintf (name, sizeof (name), "maps/%s.pts", sv.name); COM_FOpenFile (name, &f); if (!f) diff --git a/source/screen.c b/source/screen.c index 8810b34..a8e4ce8 100644 --- a/source/screen.c +++ b/source/screen.c @@ -506,7 +506,7 @@ void SCR_DrawFPS (void) fps_count = 0; lastframetime = t; } - /* Misty: I really do need to read about sprintf a bit. This thing keeps chewing on my foot! */ + /* Misty: I really do need to read about snprintf a bit. This thing keeps chewing on my foot! */ snprintf (st, sizeof(st), "%-3d FPS", lastfps); /* Misty: New trick! (for me) the ? makes this work like a if then else - IE: if cl_hudswap->int_val is not null, do first case, else (else is a : here) do second case. diff --git a/source/sv_main.c b/source/sv_main.c index 460f49b..3dea195 100644 --- a/source/sv_main.c +++ b/source/sv_main.c @@ -544,7 +544,7 @@ SVC_Log (void) Con_DPrintf ("sending log %i to %s\n", svs.logsequence - 1, NET_AdrToString (net_from)); - // sprintf (data, "stdlog %i\n", svs.logsequence-1); + // snprintf (data, sizeof (data), "stdlog %i\n", svs.logsequence-1); // strncat (data, (char *)svs.log_buf[((svs.logsequence-1)&1)], sizeof(data) - strlen (data)); snprintf (data, sizeof (data), "stdlog %i\n%s", svs.logsequence - 1,