diff options
Diffstat (limited to 'modules/pam_pwhistory')
-rw-r--r-- | modules/pam_pwhistory/opasswd.c | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/modules/pam_pwhistory/opasswd.c b/modules/pam_pwhistory/opasswd.c index 165cf5df..4541d658 100644 --- a/modules/pam_pwhistory/opasswd.c +++ b/modules/pam_pwhistory/opasswd.c @@ -169,7 +169,7 @@ check_old_pass, const char *user, const char *newpass, const char *filename, int while (!feof (oldpf)) { - char *cp, *tmp; + char *cp; ssize_t n = getline (&buf, &buflen, oldpf); cp = buf; @@ -177,16 +177,10 @@ check_old_pass, const char *user, const char *newpass, const char *filename, int if (n < 1) break; - tmp = strchr (cp, '#'); /* remove comments */ - if (tmp) - *tmp = '\0'; - while (isspace ((unsigned char)*cp)) /* remove spaces and tabs */ - ++cp; + cp[strcspn(cp, "\n")] = '\0'; if (*cp == '\0') /* ignore empty lines */ continue; - cp[strcspn(cp, "\n")] = '\0'; - if (strncmp (cp, user, strlen (user)) == 0 && cp[strlen (user)] == ':') { @@ -359,7 +353,7 @@ save_old_pass, const char *user, int howmany, const char *filename, int debug UN if (!do_create) while (!feof (oldpf)) { - char *cp, *tmp, *save; + char *cp, *save; ssize_t n = getline (&buf, &buflen, oldpf); if (n < 1) @@ -375,16 +369,10 @@ save_old_pass, const char *user, int howmany, const char *filename, int debug UN goto error_opasswd; } - tmp = strchr (cp, '#'); /* remove comments */ - if (tmp) - *tmp = '\0'; - while (isspace ((unsigned char)*cp)) /* remove spaces and tabs */ - ++cp; + cp[strcspn(cp, "\n")] = '\0'; if (*cp == '\0') /* ignore empty lines */ goto write_old_data; - cp[strcspn(cp, "\n")] = '\0'; - if (strncmp (cp, user, strlen (user)) == 0 && cp[strlen (user)] == ':') { |