Got_Saycmd: copy message content into intermediate buffer

This prevents modifying the original buffer at the cleanup
step as well as potentially writing out of bounds.
This commit is contained in:
James R 2024-02-11 05:35:42 -08:00 committed by Eidolon
parent df3b26878a
commit 388a72a89b

View file

@ -641,6 +641,7 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum)
SINT8 target;
UINT8 flags;
const char *dispname;
char buf[HU_MAXMSGLEN + 1];
char *msg;
boolean action = false;
char *ptr;
@ -650,8 +651,8 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum)
target = READSINT8(*p);
flags = READUINT8(*p);
msg = (char *)*p;
SKIPSTRINGL(*p, HU_MAXMSGLEN + 1);
msg = buf;
READSTRINGL(*p, msg, HU_MAXMSGLEN + 1);
if ((cv_mute.value || flags & (HU_CSAY|HU_SERVER_SAY)) && playernum != serverplayer && !(IsPlayerAdmin(playernum)))
{