diff options
author | Iker Pedrosa <ipedrosa@redhat.com> | 2022-09-26 12:16:53 +0200 |
---|---|---|
committer | Tomáš Mráz <tm@t8m.info> | 2022-09-27 10:00:58 +0200 |
commit | 40c271164dbcebfc5304d0537a42fb42e6b6803c (patch) | |
tree | 3b35fbb0b21b4f25ff8ff2d818ec3c760e84380a /modules/pam_lastlog | |
parent | f07fc9cac78851d3dfad1e8c54ee2671e6351853 (diff) | |
download | pam-40c271164dbcebfc5304d0537a42fb42e6b6803c.tar.gz pam-40c271164dbcebfc5304d0537a42fb42e6b6803c.tar.bz2 pam-40c271164dbcebfc5304d0537a42fb42e6b6803c.zip |
pam_lastlog: check localtime_r() return value
Check the return value of localtime_r() before calling strftime(). This
function crashes if the argument is NULL.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2012871
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Diffstat (limited to 'modules/pam_lastlog')
-rw-r--r-- | modules/pam_lastlog/pam_lastlog.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/modules/pam_lastlog/pam_lastlog.c b/modules/pam_lastlog/pam_lastlog.c index abd048df..121e7560 100644 --- a/modules/pam_lastlog/pam_lastlog.c +++ b/modules/pam_lastlog/pam_lastlog.c @@ -573,12 +573,12 @@ last_login_failed(pam_handle_t *pamh, int announce, const char *user, time_t llt time_t lf_time; lf_time = utuser.ut_tv.tv_sec; - tm = localtime_r (&lf_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 (&lf_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? */ |