From e4e9bda578bca85a0127faec8e33a2d3b3e8c87d Mon Sep 17 00:00:00 2001 From: aland Date: Thu, 23 Aug 2001 19:30:07 +0000 Subject: [PATCH] when updating the ut_name utmp entry, do NOT always smash a trailing zero on the name. The field is fixed width, so it's OK to have an 8-character username, without a trailing 0. Bug found by Michael Chernyakhovsky --- src/modules/rlm_unix/rlm_unix.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/modules/rlm_unix/rlm_unix.c b/src/modules/rlm_unix/rlm_unix.c index 64a207e..8a7b61f 100644 --- a/src/modules/rlm_unix/rlm_unix.c +++ b/src/modules/rlm_unix/rlm_unix.c @@ -489,7 +489,11 @@ static int unix_accounting(void *instance, REQUEST *request) for (vp = request->packet->vps; vp; vp = vp->next) { switch (vp->attribute) { case PW_USER_NAME: - strNcpy(ut.ut_name, (char *)vp->strvalue, sizeof(ut.ut_name)); + if (vp->length >= sizeof(ut.ut_name)) { + memcpy(ut.ut_name, (char *)vp->strvalue, sizeof(ut.ut_name)); + } else { + strNcpy(ut.ut_name, (char *)vp->strvalue, sizeof(ut.ut_name)); + } break; case PW_LOGIN_IP_HOST: case PW_FRAMED_IP_ADDRESS: -- 2.1.4