aboutsummaryrefslogtreecommitdiff
path: root/modules/pam_pwhistory/opasswd.c
diff options
context:
space:
mode:
Diffstat (limited to 'modules/pam_pwhistory/opasswd.c')
-rw-r--r--modules/pam_pwhistory/opasswd.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/modules/pam_pwhistory/opasswd.c b/modules/pam_pwhistory/opasswd.c
index f1f62aaf..58b386bd 100644
--- a/modules/pam_pwhistory/opasswd.c
+++ b/modules/pam_pwhistory/opasswd.c
@@ -188,8 +188,7 @@ check_old_pass, const char *user, const char *newpass, const char *filename, int
if (*cp == '\0') /* ignore empty lines */
continue;
- if (cp[strlen (cp) - 1] == '\n')
- cp[strlen (cp) - 1] = '\0';
+ cp[strcspn(cp, "\n")] = '\0';
if (strncmp (cp, user, strlen (user)) == 0 &&
cp[strlen (user)] == ':')
@@ -387,8 +386,7 @@ save_old_pass, const char *user, int howmany, const char *filename, int debug UN
if (*cp == '\0') /* ignore empty lines */
goto write_old_data;
- if (cp[strlen (cp) - 1] == '\n')
- cp[strlen (cp) - 1] = '\0';
+ cp[strcspn(cp, "\n")] = '\0';
if (strncmp (cp, user, strlen (user)) == 0 &&
cp[strlen (user)] == ':')