From 2d619725048f34f75b5aac20b12d18dde575b731 Mon Sep 17 00:00:00 2001 From: Nicolas Morales Date: Thu, 9 Jul 2026 20:22:02 -0400 Subject: [PATCH 1/9] botlib: zero-initialize some vectors in AAS_Reachability_Jump --- codemp/botlib/be_aas_reach.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/codemp/botlib/be_aas_reach.cpp b/codemp/botlib/be_aas_reach.cpp index 4c393b1813..2c72bb6fef 100644 --- a/codemp/botlib/be_aas_reach.cpp +++ b/codemp/botlib/be_aas_reach.cpp @@ -2113,7 +2113,10 @@ int AAS_Reachability_Jump(int area1num, int area2num) int stopevent, areas[10], numareas; float phys_jumpvel, maxjumpdistance, maxjumpheight, height, bestdist, speed; float *v1, *v2, *v3, *v4; - vec3_t beststart, beststart2, bestend, bestend2; + vec3_t beststart = {}; + vec3_t beststart2 = {}; + vec3_t bestend = {}; + vec3_t bestend2 = {}; vec3_t teststart, testend, dir, velocity, cmdmove, up = {0, 0, 1}, sidewards; aas_area_t *area1, *area2; aas_face_t *face1, *face2; From 9f7950834aede7e93073a58676e8ac37db149365 Mon Sep 17 00:00:00 2001 From: Nicolas Morales Date: Thu, 9 Jul 2026 20:25:28 -0400 Subject: [PATCH 2/9] botlib: fix (unlikely) possible omission of null terminator from various strncpy functions --- codemp/botlib/be_ai_chat.cpp | 6 ++++-- codemp/botlib/be_ai_goal.cpp | 8 ++++++-- codemp/botlib/be_ai_weap.cpp | 3 ++- codemp/botlib/l_log.cpp | 5 ++++- codemp/botlib/l_precomp.cpp | 1 + codemp/botlib/l_script.cpp | 3 ++- 6 files changed, 19 insertions(+), 7 deletions(-) diff --git a/codemp/botlib/be_ai_chat.cpp b/codemp/botlib/be_ai_chat.cpp index fb29c53660..9847d3a67b 100644 --- a/codemp/botlib/be_ai_chat.cpp +++ b/codemp/botlib/be_ai_chat.cpp @@ -347,7 +347,8 @@ void BotQueueConsoleMessage(int chatstate, int type, char *message) m->handle = cs->handle; m->time = AAS_Time(); m->type = type; - strncpy(m->message, message, MAX_MESSAGE_SIZE); + strncpy(m->message, message, MAX_MESSAGE_SIZE - 1); + m->message[MAX_MESSAGE_SIZE - 1] = '\0'; m->next = NULL; if (cs->lastmessage) { @@ -1462,7 +1463,8 @@ int BotFindMatch(char *str, bot_match_t *match, unsigned long int context) int i; bot_matchtemplate_t *ms; - strncpy(match->string, str, MAX_MESSAGE_SIZE); + strncpy(match->string, str, MAX_MESSAGE_SIZE - 1); + match->string[MAX_MESSAGE_SIZE - 1] = '\0'; //remove any trailing enters while(strlen(match->string) && match->string[strlen(match->string)-1] == '\n') diff --git a/codemp/botlib/be_ai_goal.cpp b/codemp/botlib/be_ai_goal.cpp index 88c882f6b8..5f53421f50 100644 --- a/codemp/botlib/be_ai_goal.cpp +++ b/codemp/botlib/be_ai_goal.cpp @@ -126,9 +126,11 @@ typedef struct levelitem_s struct levelitem_s *prev, *next; } levelitem_t; +#define ITEMINFO_CLASSNAME_SIZE 32 + typedef struct iteminfo_s { - char classname[32]; //classname of the item + char classname[ITEMINFO_CLASSNAME_SIZE]; //classname of the item char name[MAX_STRINGFIELD]; //name of the item char model[MAX_STRINGFIELD]; //model of the item int modelindex; //model index @@ -287,7 +289,8 @@ itemconfig_t *LoadItemConfig(char *filename) LibVarSet( "max_iteminfo", "256" ); } - strncpy( path, filename, MAX_PATH ); + strncpy( path, filename, MAX_PATH - 1 ); + path[MAX_PATH - 1] = '\0'; PC_SetBaseFolder(BOTFILESBASEFOLDER); source = LoadSourceFile( path ); if( !source ) { @@ -321,6 +324,7 @@ itemconfig_t *LoadItemConfig(char *filename) } //end if StripDoubleQuotes(token.string); strncpy(ii->classname, token.string, sizeof(ii->classname)-1); + ii->classname[ITEMINFO_CLASSNAME_SIZE - 1] = '\0'; if (!ReadStructure(source, &iteminfo_struct, (char *) ii)) { FreeMemory(ic); diff --git a/codemp/botlib/be_ai_weap.cpp b/codemp/botlib/be_ai_weap.cpp index 231f722a55..39b2a5d45a 100644 --- a/codemp/botlib/be_ai_weap.cpp +++ b/codemp/botlib/be_ai_weap.cpp @@ -224,7 +224,8 @@ weaponconfig_t *LoadWeaponConfig(char *filename) max_projectileinfo = 32; LibVarSet("max_projectileinfo", "32"); } //end if - strncpy(path, filename, MAX_PATH); + strncpy(path, filename, MAX_PATH - 1); + path[MAX_PATH - 1] = '\0'; PC_SetBaseFolder(BOTFILESBASEFOLDER); source = LoadSourceFile(path); if (!source) diff --git a/codemp/botlib/l_log.cpp b/codemp/botlib/l_log.cpp index 0a977ee6bb..f44b3bece0 100644 --- a/codemp/botlib/l_log.cpp +++ b/codemp/botlib/l_log.cpp @@ -80,7 +80,10 @@ void Log_Open(char *filename) botimport.Print(PRT_ERROR, "can't open the log file %s\n", filename); return; } //end if - strncpy(logfile.filename, filename, MAX_LOGFILENAMESIZE); + strncpy(logfile.filename, filename, MAX_LOGFILENAMESIZE - 1); + // Ensure null-termination as strncpy will not add a null terminator if + // filename is >= MAX_LOGFILENAMESIZE + logfile.filename[MAX_LOGFILENAMESIZE - 1] = '\0'; botimport.Print(PRT_MESSAGE, "Opened log %s\n", logfile.filename); } //end of the function Log_Create //=========================================================================== diff --git a/codemp/botlib/l_precomp.cpp b/codemp/botlib/l_precomp.cpp index 8089a56c0a..f3985dd9d2 100644 --- a/codemp/botlib/l_precomp.cpp +++ b/codemp/botlib/l_precomp.cpp @@ -479,6 +479,7 @@ int PC_StringizeTokens(token_t *tokens, token_t *token) for (t = tokens; t; t = t->next) { strncat(token->string, t->string, MAX_TOKEN - strlen(token->string) - 1); + token->string[MAX_TOKEN - 1] = '\0'; } //end for strncat(token->string, "\"", MAX_TOKEN - strlen(token->string) - 1); return qtrue; diff --git a/codemp/botlib/l_script.cpp b/codemp/botlib/l_script.cpp index ab49c8c62b..adf0480f22 100644 --- a/codemp/botlib/l_script.cpp +++ b/codemp/botlib/l_script.cpp @@ -811,7 +811,8 @@ int PS_ReadPunctuation(script_t *script, token_t *token) //if the script contains the punctuation if (!Q_strncmp(script->script_p, p, len)) { - strncpy(token->string, p, MAX_TOKEN); + strncpy(token->string, p, MAX_TOKEN - 1); + token->string[MAX_TOKEN - 1] = '\0'; script->script_p += len; token->type = TT_PUNCTUATION; //sub type is the number of the punctuation From 537ccee70553c0d324cec2f2bfc65f2238b5b1a2 Mon Sep 17 00:00:00 2001 From: Nicolas Morales Date: Thu, 9 Jul 2026 20:25:55 -0400 Subject: [PATCH 3/9] botlib: remove unused variable from PS_ReadEscapeCharacter --- codemp/botlib/l_script.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/codemp/botlib/l_script.cpp b/codemp/botlib/l_script.cpp index adf0480f22..f8c9399f15 100644 --- a/codemp/botlib/l_script.cpp +++ b/codemp/botlib/l_script.cpp @@ -365,7 +365,7 @@ int PS_ReadWhiteSpace(script_t *script) //============================================================================ int PS_ReadEscapeCharacter(script_t *script, char *ch) { - int c, val, i; + int c, val; //step over the leading '\\' script->script_p++; @@ -386,7 +386,7 @@ int PS_ReadEscapeCharacter(script_t *script, char *ch) case 'x': { script->script_p++; - for (i = 0, val = 0; ; i++, script->script_p++) + for (val = 0; ; script->script_p++) { c = *script->script_p; if (c >= '0' && c <= '9') c = c - '0'; @@ -407,7 +407,7 @@ int PS_ReadEscapeCharacter(script_t *script, char *ch) default: //NOTE: decimal ASCII code, NOT octal { if (*script->script_p < '0' || *script->script_p > '9') ScriptError(script, "unknown escape char"); - for (i = 0, val = 0; ; i++, script->script_p++) + for (val = 0; ; script->script_p++) { c = *script->script_p; if (c >= '0' && c <= '9') c = c - '0'; From 982d9a9189a415d69836141ce0815243e65bc0a1 Mon Sep 17 00:00:00 2001 From: Nicolas Morales Date: Thu, 9 Jul 2026 20:28:51 -0400 Subject: [PATCH 4/9] botlib: remove bot_moveresult_t_cleared macro and replace it with C++ zero-initialization in be_ai_move.cpp --- codemp/botlib/be_ai_move.cpp | 54 ++++++++++++++++++------------------ codemp/botlib/be_ai_move.h | 1 - 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/codemp/botlib/be_ai_move.cpp b/codemp/botlib/be_ai_move.cpp index 8f24960cf9..f00f7414de 100644 --- a/codemp/botlib/be_ai_move.cpp +++ b/codemp/botlib/be_ai_move.cpp @@ -1335,7 +1335,7 @@ bot_moveresult_t BotTravel_Walk(bot_movestate_t *ms, aas_reachability_t *reach) { float dist, speed; vec3_t hordir; - bot_moveresult_t_cleared( result ); + auto result = bot_moveresult_t{}; //first walk straight to the reachability start hordir[0] = reach->start[0] - ms->origin[0]; @@ -1389,7 +1389,7 @@ bot_moveresult_t BotFinishTravel_Walk(bot_movestate_t *ms, aas_reachability_t *r { vec3_t hordir; float dist, speed; - bot_moveresult_t_cleared( result ); + auto result = bot_moveresult_t{}; //if not on the ground and changed areas... don't walk back!! //(doesn't seem to help) /* @@ -1425,7 +1425,7 @@ bot_moveresult_t BotTravel_Crouch(bot_movestate_t *ms, aas_reachability_t *reach { float speed; vec3_t hordir; - bot_moveresult_t_cleared( result ); + auto result = bot_moveresult_t{}; // speed = 400; @@ -1454,7 +1454,7 @@ bot_moveresult_t BotTravel_BarrierJump(bot_movestate_t *ms, aas_reachability_t * { float dist, speed; vec3_t hordir; - bot_moveresult_t_cleared( result ); + auto result = bot_moveresult_t{}; //walk straight to reachability start hordir[0] = reach->start[0] - ms->origin[0]; @@ -1487,7 +1487,7 @@ bot_moveresult_t BotTravel_BarrierJump(bot_movestate_t *ms, aas_reachability_t * bot_moveresult_t BotFinishTravel_BarrierJump(bot_movestate_t *ms, aas_reachability_t *reach) { vec3_t hordir; - bot_moveresult_t_cleared( result ); + auto result = bot_moveresult_t{}; //if near the top or going down if (ms->velocity[2] < 250) @@ -1513,7 +1513,7 @@ bot_moveresult_t BotFinishTravel_BarrierJump(bot_movestate_t *ms, aas_reachabili bot_moveresult_t BotTravel_Swim(bot_movestate_t *ms, aas_reachability_t *reach) { vec3_t dir; - bot_moveresult_t_cleared( result ); + auto result = bot_moveresult_t{}; //swim straight to reachability end VectorSubtract(reach->start, ms->origin, dir); @@ -1539,7 +1539,7 @@ bot_moveresult_t BotTravel_WaterJump(bot_movestate_t *ms, aas_reachability_t *re { vec3_t dir, hordir; float dist; - bot_moveresult_t_cleared( result ); + auto result = bot_moveresult_t{}; //swim straight to reachability end VectorSubtract(reach->end, ms->origin, dir); @@ -1571,7 +1571,7 @@ bot_moveresult_t BotTravel_WaterJump(bot_movestate_t *ms, aas_reachability_t *re bot_moveresult_t BotFinishTravel_WaterJump(bot_movestate_t *ms, aas_reachability_t *reach) { vec3_t dir, pnt; - bot_moveresult_t_cleared( result ); + auto result = bot_moveresult_t{}; //botimport.Print(PRT_MESSAGE, "BotFinishTravel_WaterJump\n"); //if waterjumping there's nothing to do @@ -1606,7 +1606,7 @@ bot_moveresult_t BotTravel_WalkOffLedge(bot_movestate_t *ms, aas_reachability_t { vec3_t hordir, dir; float dist, speed, reachhordist; - bot_moveresult_t_cleared( result ); + auto result = bot_moveresult_t{}; //check if the bot is blocked by anything VectorSubtract(reach->start, ms->origin, dir); @@ -1705,7 +1705,7 @@ bot_moveresult_t BotFinishTravel_WalkOffLedge(bot_movestate_t *ms, aas_reachabil { vec3_t dir, hordir, end, v; float dist, speed; - bot_moveresult_t_cleared( result ); + auto result = bot_moveresult_t{}; // VectorSubtract(reach->end, ms->origin, dir); @@ -1742,7 +1742,7 @@ bot_moveresult_t BotTravel_Jump(bot_movestate_t *ms, aas_reachability_t *reach) { vec3_t hordir; float dist, gapdist, speed, horspeed, sv_jumpvel; - bot_moveresult_t_cleared( result ); + auto result = bot_moveresult_t{}; // sv_jumpvel = botlibglobals.sv_jumpvel->value; @@ -1791,7 +1791,7 @@ bot_moveresult_t BotTravel_Jump(bot_movestate_t *ms, aas_reachability_t *reach) vec3_t hordir, dir1, dir2, mins, maxs, start, end; int gapdist; float dist1, dist2, speed; - bot_moveresult_t_cleared( result ); + auto result = bot_moveresult_t{}; bsp_trace_t trace; // @@ -1864,7 +1864,7 @@ bot_moveresult_t BotTravel_Jump(bot_movestate_t *ms, aas_reachability_t *reach) // vec3_t runstart, dir1, dir2, hordir; int gapdist; float dist1, dist2, speed; - bot_moveresult_t_cleared( result ); + auto result = bot_moveresult_t{}; // AAS_JumpReachRunStart(reach, runstart); @@ -1933,7 +1933,7 @@ bot_moveresult_t BotFinishTravel_Jump(bot_movestate_t *ms, aas_reachability_t *r { vec3_t hordir, hordir2; float speed, dist; - bot_moveresult_t_cleared( result ); + auto result = bot_moveresult_t{}; //if not jumped yet if (!ms->jumpreach) return result; @@ -1969,7 +1969,7 @@ bot_moveresult_t BotTravel_Ladder(bot_movestate_t *ms, aas_reachability_t *reach vec3_t dir, viewdir;//, hordir; vec3_t origin = {0, 0, 0}; // vec3_t up = {0, 0, 1}; - bot_moveresult_t_cleared( result ); + auto result = bot_moveresult_t{}; // // if ((ms->moveflags & MFL_AGAINSTLADDER)) @@ -2022,7 +2022,7 @@ bot_moveresult_t BotTravel_Teleport(bot_movestate_t *ms, aas_reachability_t *rea { vec3_t hordir; float dist; - bot_moveresult_t_cleared( result ); + auto result = bot_moveresult_t{}; //if the bot is being teleported if (ms->moveflags & MFL_TELEPORTED) return result; @@ -2052,7 +2052,7 @@ bot_moveresult_t BotTravel_Elevator(bot_movestate_t *ms, aas_reachability_t *rea { vec3_t dir, dir1, dir2, hordir, bottomcenter; float dist, dist1, dist2, speed; - bot_moveresult_t_cleared( result ); + auto result = bot_moveresult_t{}; //if standing on the plat if (BotOnMover(ms->origin, ms->entitynum, reach)) @@ -2201,7 +2201,7 @@ bot_moveresult_t BotTravel_Elevator(bot_movestate_t *ms, aas_reachability_t *rea bot_moveresult_t BotFinishTravel_Elevator(bot_movestate_t *ms, aas_reachability_t *reach) { vec3_t bottomcenter, bottomdir, topdir; - bot_moveresult_t_cleared( result ); + auto result = bot_moveresult_t{}; // MoverBottomCenter(reach, bottomcenter); @@ -2289,7 +2289,7 @@ bot_moveresult_t BotTravel_FuncBobbing(bot_movestate_t *ms, aas_reachability_t * { vec3_t dir, dir1, dir2, hordir, bottomcenter, bob_start, bob_end, bob_origin; float dist, dist1, dist2, speed; - bot_moveresult_t_cleared( result ); + auto result = bot_moveresult_t{}; // BotFuncBobStartEnd(reach, bob_start, bob_end, bob_origin); @@ -2445,7 +2445,7 @@ bot_moveresult_t BotTravel_FuncBobbing(bot_movestate_t *ms, aas_reachability_t * bot_moveresult_t BotFinishTravel_FuncBobbing(bot_movestate_t *ms, aas_reachability_t *reach) { vec3_t bob_origin, bob_start, bob_end, dir, hordir, bottomcenter; - bot_moveresult_t_cleared( result ); + auto result = bot_moveresult_t{}; float dist, speed; // @@ -2554,7 +2554,7 @@ void BotResetGrapple(bot_movestate_t *ms) //=========================================================================== bot_moveresult_t BotTravel_Grapple(bot_movestate_t *ms, aas_reachability_t *reach) { - bot_moveresult_t_cleared( result ); + auto result = bot_moveresult_t{}; float dist, speed; vec3_t dir, viewdir, org; int state, areanum; @@ -2709,7 +2709,7 @@ bot_moveresult_t BotTravel_RocketJump(bot_movestate_t *ms, aas_reachability_t *r { vec3_t hordir; float dist, speed; - bot_moveresult_t_cleared( result ); + auto result = bot_moveresult_t{}; //botimport.Print(PRT_MESSAGE, "BotTravel_RocketJump: bah\n"); // @@ -2773,7 +2773,7 @@ bot_moveresult_t BotTravel_BFGJump(bot_movestate_t *ms, aas_reachability_t *reac { vec3_t hordir; float dist, speed; - bot_moveresult_t_cleared( result ); + auto result = bot_moveresult_t{}; //botimport.Print(PRT_MESSAGE, "BotTravel_BFGJump: bah\n"); // @@ -2833,7 +2833,7 @@ bot_moveresult_t BotFinishTravel_WeaponJump(bot_movestate_t *ms, aas_reachabilit { vec3_t hordir; float speed; - bot_moveresult_t_cleared( result ); + auto result = bot_moveresult_t{}; //if not jumped yet if (!ms->jumpreach) return result; @@ -2871,7 +2871,7 @@ bot_moveresult_t BotFinishTravel_WeaponJump(bot_movestate_t *ms, aas_reachabilit bot_moveresult_t BotTravel_JumpPad(bot_movestate_t *ms, aas_reachability_t *reach) { vec3_t hordir; - bot_moveresult_t_cleared( result ); + auto result = bot_moveresult_t{}; //first walk straight to the reachability start hordir[0] = reach->start[0] - ms->origin[0]; @@ -2895,7 +2895,7 @@ bot_moveresult_t BotFinishTravel_JumpPad(bot_movestate_t *ms, aas_reachability_t { float speed; vec3_t hordir; - bot_moveresult_t_cleared( result ); + auto result = bot_moveresult_t{}; if (!BotAirControl(ms->origin, ms->velocity, reach->end, hordir, &speed)) { @@ -2953,7 +2953,7 @@ int BotReachabilityTime(aas_reachability_t *reach) //=========================================================================== bot_moveresult_t BotMoveInGoalArea(bot_movestate_t *ms, bot_goal_t *goal) { - bot_moveresult_t_cleared( result ); + auto result = bot_moveresult_t{}; vec3_t dir; float dist, speed; diff --git a/codemp/botlib/be_ai_move.h b/codemp/botlib/be_ai_move.h index 1c0cd08ac7..92fc15ad24 100644 --- a/codemp/botlib/be_ai_move.h +++ b/codemp/botlib/be_ai_move.h @@ -106,7 +106,6 @@ typedef struct bot_moveresult_s vec3_t ideal_viewangles; //ideal viewangles for the movement } bot_moveresult_t; -#define bot_moveresult_t_cleared(x) bot_moveresult_t (x) = {0, 0, 0, 0, 0, 0, 0, {0, 0, 0}, {0, 0, 0}} typedef struct bot_avoidspot_s { From e129dd1f4387a1b6b9aea9ca28dc5ca1543def71 Mon Sep 17 00:00:00 2001 From: Nicolas Morales Date: Thu, 9 Jul 2026 20:29:20 -0400 Subject: [PATCH 5/9] botlib: fix another strncpy truncation warning --- codemp/botlib/be_ai_chat.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/codemp/botlib/be_ai_chat.cpp b/codemp/botlib/be_ai_chat.cpp index 9847d3a67b..922cc982ba 100644 --- a/codemp/botlib/be_ai_chat.cpp +++ b/codemp/botlib/be_ai_chat.cpp @@ -2123,7 +2123,8 @@ bot_chat_t *BotLoadInitialChat(char *chatfile, char *chatname) if (pass) { chattype = (bot_chattype_t *) ptr; - strncpy(chattype->name, token.string, MAX_CHATTYPE_NAME); + strncpy(chattype->name, token.string, MAX_CHATTYPE_NAME - 1); + chattype->name[MAX_CHATTYPE_NAME - 1] = '\0'; chattype->firstchatmessage = NULL; //add the chat type to the chat chattype->next = chat->types; From 45678331ac88c87b919f4983941ddc22708acbb4 Mon Sep 17 00:00:00 2001 From: Nicolas Morales Date: Thu, 9 Jul 2026 20:30:00 -0400 Subject: [PATCH 6/9] botlib: fix strncpy truncation warning --- codemp/botlib/be_ai_goal.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/codemp/botlib/be_ai_goal.cpp b/codemp/botlib/be_ai_goal.cpp index 5f53421f50..350a3dbbc2 100644 --- a/codemp/botlib/be_ai_goal.cpp +++ b/codemp/botlib/be_ai_goal.cpp @@ -168,6 +168,8 @@ typedef struct itemconfig_s iteminfo_t *iteminfo; } itemconfig_t; +#define MAX_GOAL_NAME_LEN 32 + //goal state typedef struct bot_goalstate_s { @@ -695,8 +697,9 @@ void BotGoalName(int number, char *name, int size) { if (li->number == number) { - strncpy(name, itemconfig->iteminfo[li->iteminfo].name, size-1); - name[size-1] = '\0'; + int len = (int)strlen( itemconfig->iteminfo[li->iteminfo].name ); + memcpy(name, itemconfig->iteminfo[li->iteminfo].name, ( len < size ? len : size ) - 1 ); + name[size - 1] = '\0'; return; } //end for } //end for @@ -728,7 +731,7 @@ void BotDumpAvoidGoals(int goalstate) { int i; bot_goalstate_t *gs; - char name[32]; + char name[MAX_GOAL_NAME_LEN]; gs = BotGoalStateFromHandle(goalstate); if (!gs) return; @@ -736,7 +739,7 @@ void BotDumpAvoidGoals(int goalstate) { if (gs->avoidgoaltimes[i] >= AAS_Time()) { - BotGoalName(gs->avoidgoals[i], name, 32); + BotGoalName(gs->avoidgoals[i], name, MAX_GOAL_NAME_LEN); Log_Write("avoid goal %s, number %d for %f seconds", name, gs->avoidgoals[i], gs->avoidgoaltimes[i] - AAS_Time()); } //end if @@ -1192,13 +1195,13 @@ void BotDumpGoalStack(int goalstate) { int i; bot_goalstate_t *gs; - char name[32]; + char name[MAX_GOAL_NAME_LEN]; gs = BotGoalStateFromHandle(goalstate); if (!gs) return; for (i = 1; i <= gs->goalstacktop; i++) { - BotGoalName(gs->goalstack[i].number, name, 32); + BotGoalName(gs->goalstack[i].number, name, MAX_GOAL_NAME_LEN); Log_Write("%d: %s", i, name); } //end for } //end of the function BotDumpGoalStack From 2e04d6f785c1c84d0de9b937b46a2e9815a131bb Mon Sep 17 00:00:00 2001 From: Nicolas Morales Date: Fri, 10 Jul 2026 09:17:38 -0400 Subject: [PATCH 7/9] botlib: fix bug with my fix for c-style string manip --- codemp/botlib/be_ai_goal.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/codemp/botlib/be_ai_goal.cpp b/codemp/botlib/be_ai_goal.cpp index 350a3dbbc2..b2fee98a8a 100644 --- a/codemp/botlib/be_ai_goal.cpp +++ b/codemp/botlib/be_ai_goal.cpp @@ -689,6 +689,7 @@ void BotInitLevelItems(void) //=========================================================================== void BotGoalName(int number, char *name, int size) { + const size_t max_len = (size_t)(size - 1); levelitem_t *li; if (!itemconfig) return; @@ -697,9 +698,10 @@ void BotGoalName(int number, char *name, int size) { if (li->number == number) { - int len = (int)strlen( itemconfig->iteminfo[li->iteminfo].name ); - memcpy(name, itemconfig->iteminfo[li->iteminfo].name, ( len < size ? len : size ) - 1 ); - name[size - 1] = '\0'; + const size_t len = strlen( itemconfig->iteminfo[li->iteminfo].name ); + const size_t count = len < max_len ? len : max_len; + memcpy(name, itemconfig->iteminfo[li->iteminfo].name, count ); + name[count] = '\0'; return; } //end for } //end for From 2fb40128eddeb54036f54fe876939edf1d568e29 Mon Sep 17 00:00:00 2001 From: Nicolas Morales Date: Fri, 10 Jul 2026 09:18:38 -0400 Subject: [PATCH 8/9] botlib: remove unncessary comment --- codemp/botlib/l_log.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/codemp/botlib/l_log.cpp b/codemp/botlib/l_log.cpp index f44b3bece0..16636f1a3e 100644 --- a/codemp/botlib/l_log.cpp +++ b/codemp/botlib/l_log.cpp @@ -81,8 +81,6 @@ void Log_Open(char *filename) return; } //end if strncpy(logfile.filename, filename, MAX_LOGFILENAMESIZE - 1); - // Ensure null-termination as strncpy will not add a null terminator if - // filename is >= MAX_LOGFILENAMESIZE logfile.filename[MAX_LOGFILENAMESIZE - 1] = '\0'; botimport.Print(PRT_MESSAGE, "Opened log %s\n", logfile.filename); } //end of the function Log_Create From cdced82305c7d1bb739f9d8c212f3eed5393eb4b Mon Sep 17 00:00:00 2001 From: Nicolas Morales Date: Fri, 10 Jul 2026 11:41:03 -0400 Subject: [PATCH 9/9] botlib: fix user defined literal syntax (warning in clang-22) --- shared/qcommon/safe/gsl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/qcommon/safe/gsl.h b/shared/qcommon/safe/gsl.h index 3f29f2bd91..7c2e657d9c 100644 --- a/shared/qcommon/safe/gsl.h +++ b/shared/qcommon/safe/gsl.h @@ -18,7 +18,7 @@ inline gsl::cstring_span vs2013hack_cstring_view_literal( const char (&str)[leng #else # define CSTRING_VIEW(x) x ## _v /** gsl::cstring_span from string literal (without null-termination) */ -inline gsl::cstring_span operator"" _v( const char* str, std::size_t length ) +inline gsl::cstring_span operator""_v( const char* str, std::size_t length ) { return{ str, str + length }; }