From 4cdb0fd0d3b4255a9994ce302d6df76d251f7b75 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Sun, 14 Oct 2018 17:29:51 +0200 Subject: ar: Assume epoch if ar_date is bogus. If the ar header contains a bogus ar_date then in verbose mode we would get a NULL pointer from localtime. Just assume the entry was created during the epoch. https://sourceware.org/bugzilla/show_bug.cgi?id=23754 Signed-off-by: Mark Wielaard --- src/ar.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/ar.c') diff --git a/src/ar.c b/src/ar.c index 6f98f75d..d70f1f46 100644 --- a/src/ar.c +++ b/src/ar.c @@ -539,8 +539,14 @@ do_oper_extract (int oper, const char *arfname, char **argv, int argc, else if (oper == oper_list) { char datestr[100]; - strftime (datestr, sizeof (datestr), "%b %e %H:%M %Y", - localtime (&arhdr->ar_date)); + struct tm *tp = localtime (&arhdr->ar_date); + if (tp == NULL) + { + time_t time = 0; + tp = localtime (&time); + } + + strftime (datestr, sizeof (datestr), "%b %e %H:%M %Y", tp); printf ("%c%c%c%c%c%c%c%c%c %u/%u %6ju %s %s\n", (arhdr->ar_mode & S_IRUSR) ? 'r' : '-', -- cgit v1.2.3