Investigated PVS report for g_cmds and use snprintf instead of sprintf

This commit is contained in:
BjossiAlfreds 2019-09-23 19:44:35 +00:00
parent 81e59effff
commit b7f6d9da91
1 changed files with 6 additions and 4 deletions

View File

@ -1224,7 +1224,7 @@ Cmd_Ent_Count_f(edict_t *ent)
void
Cmd_PlayerList_f(edict_t *ent)
{
int i;
int i, text_len;
char st[80];
char text[1400];
edict_t *e2;
@ -1235,7 +1235,7 @@ Cmd_PlayerList_f(edict_t *ent)
}
/* connect time, ping, score, name */
*text = 0;
*text = '\0';
for (i = 0, e2 = g_edicts + 1; i < maxclients->value; i++, e2++)
{
@ -1251,9 +1251,11 @@ Cmd_PlayerList_f(edict_t *ent)
e2->client->pers.netname,
e2->client->resp.spectator ? " (spectator)" : "");
if (strlen(text) + strlen(st) > sizeof(text) - 50)
text_len = strlen(text);
if ((text_len + strlen(st)) > (sizeof(text) - 50))
{
sprintf(text + strlen(text), "And more...\n");
snprintf(text + text_len, sizeof(text) - text_len, "And more...\n");
gi.cprintf(ent, PRINT_HIGH, "%s", text);
return;
}