From: Iker Pedrosa Date: Thu, 6 Oct 2022 08:05:44 +0000 (+0200) Subject: lastlog: check for localtime() return value X-Git-Tag: 4.13~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fbf275da195b3f3c762472f6660497f70cb3531e;p=thirdparty%2Fshadow.git lastlog: check for localtime() return value Signed-off-by: Tomáš Mráz Signed-off-by: Iker Pedrosa --- diff --git a/src/lastlog.c b/src/lastlog.c index 0d4b5fd22..f5c0a5cc8 100644 --- a/src/lastlog.c +++ b/src/lastlog.c @@ -150,9 +150,12 @@ static void print_one (/*@null@*/const struct passwd *pw) ll_time = ll.ll_time; tm = localtime (&ll_time); - strftime (ptime, sizeof (ptime), "%a %b %e %H:%M:%S %z %Y", tm); - cp = ptime; - + if (tm == NULL) { + cp = "(unknown)"; + } else { + strftime (ptime, sizeof (ptime), "%a %b %e %H:%M:%S %z %Y", tm); + cp = ptime; + } if (ll.ll_time == (time_t) 0) { cp = _("**Never logged in**\0"); }