From d65f138fbc784911399e5afe66c9661e0136b43d Mon Sep 17 00:00:00 2001 From: Tomas Mraz Date: Mon, 21 Jul 2014 16:31:38 +0200 Subject: Make pam_pwhistory and pam_unix tolerant of corrupted opasswd file. * modules/pam_pwhistory/opasswd.c (parse_entry): Test for missing fields in opasswd entry and return error. * modules/pam_unix/passverify.c (save_old_password): Test for missing fields in opasswd entry and skip it. --- modules/pam_pwhistory/opasswd.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'modules/pam_pwhistory/opasswd.c') diff --git a/modules/pam_pwhistory/opasswd.c b/modules/pam_pwhistory/opasswd.c index 836d713e..e6cf3469 100644 --- a/modules/pam_pwhistory/opasswd.c +++ b/modules/pam_pwhistory/opasswd.c @@ -82,10 +82,15 @@ parse_entry (char *line, opwd *data) { const char delimiters[] = ":"; char *endptr; + char *count; data->user = strsep (&line, delimiters); data->uid = strsep (&line, delimiters); - data->count = strtol (strsep (&line, delimiters), &endptr, 10); + count = strsep (&line, delimiters); + if (count == NULL) + return 1; + + data->count = strtol (count, &endptr, 10); if (endptr != NULL && *endptr != '\0') return 1; -- cgit v1.2.3