diff --git a/src/g_cmds.c b/src/g_cmds.c index 0d07086..3e6a136 100644 --- a/src/g_cmds.c +++ b/src/g_cmds.c @@ -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; }