From d1ea5176ffc9ef93c4b34d59ceb0dbb9d15d9040 Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Mon, 23 Jul 2018 02:55:59 +0000 Subject: [PATCH] Fix -Wformat-overflow warnings git-svn-id: https://svn.eduke32.com/eduke32@6951 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/duke3d/src/astub.cpp | 8 ++++---- source/duke3d/src/common.cpp | 4 ++-- source/duke3d/src/m32exec.cpp | 12 ++++++------ source/duke3d/src/premap.cpp | 6 +++--- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/source/duke3d/src/astub.cpp b/source/duke3d/src/astub.cpp index 82bcdffc1..04450002d 100644 --- a/source/duke3d/src/astub.cpp +++ b/source/duke3d/src/astub.cpp @@ -715,9 +715,9 @@ const char *ExtGetSectorCaption(int16_t sectnum) { Bstrcpy(lo, ExtGetSectorType(sector[sectnum].lotag)); if (!in3dmode()) - Bsprintf(tempbuf,"%hu,%hu %s", TrackerCast(sector[sectnum].hitag), TrackerCast(sector[sectnum].lotag), lo); + Bsnprintf(tempbuf, sizeof(tempbuf), "%hu,%hu %s", TrackerCast(sector[sectnum].hitag), TrackerCast(sector[sectnum].lotag), lo); else - Bsprintf(tempbuf,"%hu %s", TrackerCast(sector[sectnum].lotag), lo); + Bsnprintf(tempbuf, sizeof(tempbuf), "%hu %s", TrackerCast(sector[sectnum].lotag), lo); } return tempbuf; } @@ -767,7 +767,7 @@ const char *ExtGetWallCaption(int16_t wallnum) #endif { taglab_handle1(lt&1, wall[wallnum].lotag, lostr); - Bsprintf(tempbuf, "%s,%s", histr, lostr); + Bsnprintf(tempbuf, sizeof(tempbuf), "%s,%s", histr, lostr); } } @@ -870,7 +870,7 @@ const char *SectorEffectorText(int32_t spritenum) else { if (cursprite == spritenum) - Bsprintf(tempbuf, "SE %d %s", TrackerCast(sprite[spritenum].lotag), lo); + Bsnprintf(tempbuf, sizeof(tempbuf), "SE %d %s", TrackerCast(sprite[spritenum].lotag), lo); else Bstrcpy(tempbuf, lo); } diff --git a/source/duke3d/src/common.cpp b/source/duke3d/src/common.cpp index 16fa613c0..72b50837c 100644 --- a/source/duke3d/src/common.cpp +++ b/source/duke3d/src/common.cpp @@ -412,7 +412,7 @@ void G_LoadGroups(int32_t autoload) if (getcwd(cwd, BMAX_PATH)) { - Bsprintf(cwd, "%s/%s", cwd, g_modDir); + Bsnprintf(cwd, sizeof(cwd), "%s/%s", cwd, g_modDir); if (!Bstrcmp(g_rootDir, cwd)) { if (addsearchpath(cwd) == -2) @@ -422,7 +422,7 @@ void G_LoadGroups(int32_t autoload) } #ifdef USE_OPENGL - Bsprintf(cwd, "%s/%s", g_modDir, TEXCACHEFILE); + Bsnprintf(cwd, sizeof(cwd), "%s/%s", g_modDir, TEXCACHEFILE); Bstrcpy(TEXCACHEFILE, cwd); #endif } diff --git a/source/duke3d/src/m32exec.cpp b/source/duke3d/src/m32exec.cpp index 080d746ac..9883ccd4f 100644 --- a/source/duke3d/src/m32exec.cpp +++ b/source/duke3d/src/m32exec.cpp @@ -2426,8 +2426,8 @@ badindex: switch (code&M32_VARTYPE_MASK) { case M32_FLAG_ARRAY: - Bsprintf(buf, "%s[%s]", aGameArrays[code&(MAXGAMEARRAYS-1)].szLabel? - aGameArrays[code&(MAXGAMEARRAYS-1)].szLabel:"???", buf2); + Bsnprintf(buf, sizeof(buf), "%s[%s]", aGameArrays[code&(MAXGAMEARRAYS-1)].szLabel + ? aGameArrays[code&(MAXGAMEARRAYS-1)].szLabel : "???", buf2); break; case M32_FLAG_STRUCT: { @@ -2441,14 +2441,14 @@ badindex: memberid -= LIGHT_X; } - Bsprintf(buf, "%s[%s].%s", pp1[code&3], buf2, pp2[code&3][memberid].name); + Bsnprintf(buf, sizeof(buf), "%s[%s].%s", pp1[code&3], buf2, pp2[code&3][memberid].name); } break; case M32_FLAG_VAR: - Bsprintf(buf, "???"); + Bstrcpy(buf, "???"); break; case M32_FLAG_LOCAL: - Bsprintf(buf, ".local[%s]", buf2); + Bsnprintf(buf, sizeof(buf), ".local[%s]", buf2); break; } } @@ -2465,7 +2465,7 @@ badindex: Bstrcat(buf2, buf); } - Bsprintf(buf, "%s%s", buf2, aGameVars[code].szLabel ? aGameVars[code].szLabel : "???"); + Bsnprintf(buf, sizeof(buf), "%s%s", buf2, aGameVars[code].szLabel ? aGameVars[code].szLabel : "???"); } OSD_Printf("L%d: %s%s=%d\n", g_errorLineNum, negate?"-":"", buf, val); diff --git a/source/duke3d/src/premap.cpp b/source/duke3d/src/premap.cpp index 645822a8a..b3dd93e45 100644 --- a/source/duke3d/src/premap.cpp +++ b/source/duke3d/src/premap.cpp @@ -1809,12 +1809,12 @@ int G_EnterLevel(int gameMode) { if (g_gameNamePtr) #ifdef EDUKE32_STANDALONE - Bsprintf(apptitle, "%s - %s", boardfilename, g_gameNamePtr); + Bsnprintf(apptitle, sizeof(apptitle), "%s - %s", boardfilename, g_gameNamePtr); #else - Bsprintf(apptitle, "%s - %s - " APPNAME, boardfilename, g_gameNamePtr); + Bsnprintf(apptitle, sizeof(apptitle), "%s - %s - " APPNAME, boardfilename, g_gameNamePtr); #endif else - Bsprintf(apptitle, "%s - " APPNAME, boardfilename); + Bsnprintf(apptitle, sizeof(apptitle), "%s - " APPNAME, boardfilename); } else {