client: tidy up snprintf handling in CL_ProcessUserInfo

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
This commit is contained in:
Kevin Shanahan 2012-12-18 21:18:25 +10:30
parent 0ebd2471f1
commit 5ca9e3f44c

View File

@ -951,8 +951,14 @@ CL_ProcessUserinfo
static void
CL_ProcessUserInfo(int slot, player_info_t * player)
{
strncpy(player->name, Info_ValueForKey(player->userinfo, "name"),
sizeof(player->name) - 1);
int len;
char *name;
name = Info_ValueForKey(player->userinfo, "name");
len = snprintf(player->name, sizeof(player->name), "%s", name);
if (len > sizeof(player->name) - 1)
player->name[sizeof(player->name) - 1] = 0;
player->topcolor = atoi(Info_ValueForKey(player->userinfo, "topcolor"));
player->bottomcolor =
atoi(Info_ValueForKey(player->userinfo, "bottomcolor"));