diff options
Diffstat (limited to 'modules/pam_unix')
-rw-r--r-- | modules/pam_unix/support.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/modules/pam_unix/support.c b/modules/pam_unix/support.c index 5dd3b946..df5044e9 100644 --- a/modules/pam_unix/support.c +++ b/modules/pam_unix/support.c @@ -350,15 +350,16 @@ int _unix_getpwnam(pam_handle_t *pamh, const char *name, char *buf = NULL; int matched = 0; char *slogin, *spasswd, *suid, *sgid, *sgecos, *shome, *sshell, *p; - size_t retlen, userlen; + size_t retlen; - userlen = strlen(name); if (!matched && files && strchr(name, ':') == NULL) { passwd = fopen("/etc/passwd", "r"); if (passwd != NULL) { - size_t n = 0; + size_t n = 0, userlen; ssize_t r; + userlen = strlen(name); + while ((r = getline(&buf, &n, passwd)) != -1) { if ((size_t)r > userlen && (buf[userlen] == ':') && (strncmp(name, buf, userlen) == 0)) { |