From 5ca9e3f44ca0340a69b1e4d41425ccf0cb1a6f5b Mon Sep 17 00:00:00 2001 From: Kevin Shanahan Date: Tue, 18 Dec 2012 21:18:25 +1030 Subject: [PATCH] client: tidy up snprintf handling in CL_ProcessUserInfo Signed-off-by: Kevin Shanahan --- QW/client/cl_parse.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/QW/client/cl_parse.c b/QW/client/cl_parse.c index cd9be82..13f44d4 100644 --- a/QW/client/cl_parse.c +++ b/QW/client/cl_parse.c @@ -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"));