From c667083c8172727823fc2ca380db7496f1df1938 Mon Sep 17 00:00:00 2001 From: "ed@s5h.net" Date: Sat, 7 Mar 2020 16:49:17 +0000 Subject: [PATCH 1/2] Fix segfault when time is unreadable Adding myself to contributors Closes #130 --- README | 1 + src/faillog.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/README b/README index c0c03f2d..cf54ca8e 100644 --- a/README +++ b/README @@ -59,6 +59,7 @@ Dave Hagewood David A. Holland David Frey Ed Carp +Ed Neville Eric W. Biederman" Floody Frank Denis diff --git a/src/faillog.c b/src/faillog.c index 1309dad4..3ab48db3 100644 --- a/src/faillog.c +++ b/src/faillog.c @@ -163,6 +163,10 @@ static void print_one (/*@null@*/const struct passwd *pw, bool force) } tm = localtime (&fl.fail_time); + if (!tm) { + fprintf (stderr, "Cannot read time from faillog.\n"); + exit (EXIT_FAILURE); + } #ifdef HAVE_STRFTIME strftime (ptime, sizeof (ptime), "%D %H:%M:%S %z", tm); cp = ptime; From 8a2e3d500c9ea2b0f84e22b99e44ccf0aabe8e2d Mon Sep 17 00:00:00 2001 From: ed Date: Mon, 9 Mar 2020 18:01:32 +0000 Subject: [PATCH 2/2] Replacing exit with return --- src/faillog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/faillog.c b/src/faillog.c index 3ab48db3..e2c78383 100644 --- a/src/faillog.c +++ b/src/faillog.c @@ -165,7 +165,7 @@ static void print_one (/*@null@*/const struct passwd *pw, bool force) tm = localtime (&fl.fail_time); if (!tm) { fprintf (stderr, "Cannot read time from faillog.\n"); - exit (EXIT_FAILURE); + return; } #ifdef HAVE_STRFTIME strftime (ptime, sizeof (ptime), "%D %H:%M:%S %z", tm);