Skip to content

Commit 7b45512

Browse files
authored
feat(core): message overflow protection
Added overflow protection for console messages to prevent exceeding the maximum allowed length.
1 parent 0fe1330 commit 7b45512

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

addons/sourcemod/scripting/ConsoleChatManager.sp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ enum EHudNotify
3737
}
3838

3939
#define MAXLENGTH_INPUT 512
40+
#define MAX_SAYTEXT2_LENGTH 249
4041
#define NORMALHUD 1
4142

4243
ConVar g_hCVar_ConsoleMessage;
@@ -80,7 +81,7 @@ public Plugin myinfo =
8081
name = "ConsoleChatManager-Lite",
8182
author = "Franc1sco Franug, maxime1907, inGame, AntiTeal, Oylsister, .Rushaway, tilgep, koen",
8283
description = "Interact with console messages",
83-
version = "2.4.4",
84+
version = "2.4.5",
8485
url = ""
8586
};
8687

@@ -679,6 +680,13 @@ stock void SendServerMessage(const char[] sMessage, bool bScript = false)
679680
strcopy(sTrimText, sizeof(sTrimText), sText);
680681
RemoveColorCodes(sTrimText);
681682

683+
// Overflow protection
684+
if (MAX_SAYTEXT2_LENGTH - strlen(sTrimText) <= 1)
685+
{
686+
PrintToServer("[ConsoleChatManager] Message is too long to be sent to clients, skipping display. Message: %s", sTrimText);
687+
return;
688+
}
689+
682690
if (g_bBlockSpam)
683691
{
684692
int currentTime = GetTime();
@@ -742,4 +750,4 @@ stock void SendServerMessage(const char[] sMessage, bool bScript = false)
742750
}
743751
}
744752
}
745-
}
753+
}

0 commit comments

Comments
 (0)