summaryrefslogtreecommitdiff
path: root/modules/pam_unix/unix_chkpwd.c
diff options
context:
space:
mode:
Diffstat (limited to 'modules/pam_unix/unix_chkpwd.c')
-rw-r--r--modules/pam_unix/unix_chkpwd.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/modules/pam_unix/unix_chkpwd.c b/modules/pam_unix/unix_chkpwd.c
index b0509e47..592ea5b3 100644
--- a/modules/pam_unix/unix_chkpwd.c
+++ b/modules/pam_unix/unix_chkpwd.c
@@ -172,9 +172,8 @@ static char *getuidname(uid_t uid)
if (pw == NULL)
return NULL;
- memset(username, 0, 32);
- strncpy(username, pw->pw_name, 32);
- username[31] = '\0';
+ strncpy(username, pw->pw_name, sizeof(username));
+ username[sizeof(username) - 1] = '\0';
return username;
}