summaryrefslogtreecommitdiff
path: root/modules/pam_lastlog
diff options
context:
space:
mode:
authorTomas Mraz <tmraz@fedoraproject.org>2016-03-04 14:19:01 +0100
committerTomas Mraz <tmraz@fedoraproject.org>2016-03-04 14:19:01 +0100
commit11db6fd23dee9cf400a260b371edbd6091a96171 (patch)
tree0acb3f5c0a51bf4f2127b8e5ea639e2086dbc1ce /modules/pam_lastlog
parent144f8c64cbb906c1f4a7f6bf5fbed16e35ae7bc2 (diff)
Add checks for localtime() returning NULL.
* modules/pam_lastlog/pam_lastlog.c (last_login_read): Check for localtime_r returning NULL. * modules/pam_tally2/pam_tally2.c (print_one): Check for localtime returning NULL.
Diffstat (limited to 'modules/pam_lastlog')
-rw-r--r--modules/pam_lastlog/pam_lastlog.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/modules/pam_lastlog/pam_lastlog.c b/modules/pam_lastlog/pam_lastlog.c
index 50d33e40..76a33e41 100644
--- a/modules/pam_lastlog/pam_lastlog.c
+++ b/modules/pam_lastlog/pam_lastlog.c
@@ -276,12 +276,12 @@ last_login_read(pam_handle_t *pamh, int announce, int last_fd, uid_t uid, time_t
time_t ll_time;
ll_time = last_login.ll_time;
- tm = localtime_r (&ll_time, &tm_buf);
- strftime (the_time, sizeof (the_time),
- /* TRANSLATORS: "strftime options for date of last login" */
- _(" %a %b %e %H:%M:%S %Z %Y"), tm);
-
- date = the_time;
+ if ((tm = localtime_r (&ll_time, &tm_buf)) != NULL) {
+ strftime (the_time, sizeof (the_time),
+ /* TRANSLATORS: "strftime options for date of last login" */
+ _(" %a %b %e %H:%M:%S %Z %Y"), tm);
+ date = the_time;
+ }
}
/* we want & have the host? */