Skip to content

Commit

Permalink
Adjust TextMsg/SayText maximum buffer length from 190 to 187 due to "…
Browse files Browse the repository at this point in the history
…%s" parameter added in #763
  • Loading branch information
Arkshine committed Oct 23, 2019
1 parent 4a2aecf commit be3f2f5
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions amxmodx/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,15 @@ void UTIL_DHudMessage(edict_t *pEntity, const hudtextparms_t &textparms, const c
MESSAGE_END();
}

/* warning - buffer of msg must be longer than 190 chars!
/* warning - buffer of msg must be longer than 187 chars!
(here in AMX it is always longer) */
void UTIL_ClientPrint(edict_t *pEntity, int msg_dest, char *msg)
{
if (!gmsgTextMsg)
return; // :TODO: Maybe output a warning log?

char c = msg[190];
msg[190] = 0; // truncate without checking with strlen()
char c = msg[187];
msg[187] = 0; // truncate without checking with strlen()

if (pEntity)
MESSAGE_BEGIN(MSG_ONE, gmsgTextMsg, NULL, pEntity);
Expand All @@ -279,23 +279,23 @@ void UTIL_ClientPrint(edict_t *pEntity, int msg_dest, char *msg)
WRITE_STRING("%s");
WRITE_STRING(msg);
MESSAGE_END();
msg[190] = c;
msg[187] = c;
}

void UTIL_ClientSayText(edict_t *pEntity, int sender, char *msg)
{
if (!gmsgSayText)
return; // :TODO: Maybe output a warning log?

char c = msg[190];
msg[190] = 0; // truncate without checking with strlen()
char c = msg[187];
msg[187] = 0; // truncate without checking with strlen()

MESSAGE_BEGIN(MSG_ONE, gmsgSayText, NULL, pEntity);
WRITE_BYTE(sender);
WRITE_STRING("%s");
WRITE_STRING(msg);
MESSAGE_END();
msg[190] = c;
msg[187] = c;
}

void UTIL_TeamInfo(edict_t *pEntity, int playerIndex, const char *pszTeamName)
Expand Down

0 comments on commit be3f2f5

Please sign in to comment.