From 9c6deef2a013d5fb3d7a807874e76f6256b28b8a Mon Sep 17 00:00:00 2001 From: havoc Date: Thu, 2 Jun 2005 11:42:18 +0000 Subject: [PATCH] fix some potential buffer overflows git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5377 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_screen.c | 8 ++++---- gl_draw.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cl_screen.c b/cl_screen.c index 7ccced75..650c64dc 100644 --- a/cl_screen.c +++ b/cl_screen.c @@ -324,25 +324,25 @@ void R_TimeReport(char *desc) r_timereport_current = Sys_DoubleTime(); t = (int) ((r_timereport_current - r_timereport_temp) * 1000000.0); - sprintf(tempbuf, "%8i %s", t, desc); + dpsnprintf(tempbuf, sizeof(tempbuf), "%8i %s", t, desc); length = strlen(tempbuf); while (length < 20) tempbuf[length++] = ' '; tempbuf[length] = 0; if (speedstringcount + length > (vid_conwidth.integer / 8)) { - strcat(r_speeds_string, "\n"); + strlcat(r_speeds_string, "\n", sizeof(r_speeds_string)); speedstringcount = 0; } // skip the space at the beginning if it's the first on the line if (speedstringcount == 0) { - strcat(r_speeds_string, tempbuf + 1); + strlcat(r_speeds_string, tempbuf + 1, sizeof(r_speeds_string)); speedstringcount = length - 1; } else { - strcat(r_speeds_string, tempbuf); + strlcat(r_speeds_string, tempbuf, sizeof(r_speeds_string)); speedstringcount += length; } } diff --git a/gl_draw.c b/gl_draw.c index 135cac69..fc19b76f 100644 --- a/gl_draw.c +++ b/gl_draw.c @@ -292,7 +292,7 @@ cachepic_t *Draw_CachePic (const char *path, qboolean persistent) if (numcachepics == MAX_CACHED_PICS) Sys_Error ("numcachepics == MAX_CACHED_PICS"); pic = cachepics + (numcachepics++); - strcpy (pic->name, path); + strlcpy (pic->name, path, sizeof(pic->name)); // link into list pic->chain = cachepichash[hashkey]; cachepichash[hashkey] = pic; -- 2.39.2