Merge branch 'fix-say-cmd' into 'master'

Fix chat message buffer handling

See merge request KartKrew/Kart!2400
This commit is contained in:
AJ Martinez 2024-05-21 00:30:31 +00:00
commit 4ee43d6e10
3 changed files with 10 additions and 13 deletions

View file

@ -4727,8 +4727,7 @@ static void PT_Say(int node)
{
size_t i;
const size_t j = strlen(say.message);
for (i = 0; i < j; i++)
for (i = 0; i < sizeof say.message && say.message[i]; i++)
{
if (say.message[i] & 0x80)
{

View file

@ -395,7 +395,7 @@ struct resultsall_pak
struct say_pak
{
char message[HU_MAXMSGLEN + 1];
char message[HU_MAXMSGLEN];
UINT8 target;
UINT8 flags;
UINT8 source;

View file

@ -544,8 +544,8 @@ void HU_AddChatText(const char *text, boolean playsound)
void DoSayCommand(char *message, SINT8 target, UINT8 flags, UINT8 source)
{
char buf[2 + HU_MAXMSGLEN + 1];
char *msg = &buf[3];
char buf[3 + HU_MAXMSGLEN];
char *p = buf;
// Enforce shout for the dedicated server.
if (dedicated && source == serverplayer && !(flags & HU_CSAY))
@ -553,14 +553,12 @@ void DoSayCommand(char *message, SINT8 target, UINT8 flags, UINT8 source)
flags |= HU_SHOUT;
}
buf[0] = target;
buf[1] = flags;
buf[2] = source;
msg[0] = '\0';
WRITESINT8(p, target);
WRITEUINT8(p, flags);
WRITEUINT8(p, source);
WRITESTRINGN(p, message, HU_MAXMSGLEN);
strcpy(msg, message);
SendNetXCmd(XD_SAY, buf, strlen(msg) + 1 + msg-buf);
SendNetXCmd(XD_SAY, buf, p - buf);
}
/** Send a message to everyone.
@ -690,7 +688,7 @@ static void Got_Saycmd(const UINT8 **p, INT32 playernum)
flags = READUINT8(*p);
playernum = READUINT8(*p);
msg = buf;
READSTRINGL(*p, msg, HU_MAXMSGLEN + 1);
READSTRINGN(*p, msg, HU_MAXMSGLEN);
//check for invalid characters (0x80 or above)
{