handle ctime returning NULL.

This commit is contained in:
christos 2010-04-02 15:13:26 +00:00
parent b22f104713
commit bd7ae6bd09
3 changed files with 13 additions and 9 deletions

View File

@ -34,7 +34,7 @@
#include "ftpd_locl.h"
__RCSID("$Heimdal: kauth.c 15666 2005-07-19 17:08:11Z lha $"
"$NetBSD: kauth.c,v 1.2 2008/03/22 08:36:50 mlelstv Exp $");
"$NetBSD: kauth.c,v 1.3 2010/04/02 15:17:52 christos Exp $");
#if defined(KRB4) || defined(KRB5)
@ -238,8 +238,9 @@ short_date(int32_t dp)
char *cp;
time_t t = (time_t)dp;
if (t == (time_t)(-1L)) return "*** Never *** ";
cp = ctime(&t) + 4;
if (t == (time_t)(-1L) || (cp = ctime(&t)) == NULL)
return "*** Never *** ";
cp += 4;
cp[15] = '\0';
return (cp);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: pfkey_dump.c,v 1.16 2007/07/18 12:07:50 vanhu Exp $ */
/* $NetBSD: pfkey_dump.c,v 1.17 2010/04/02 15:13:26 christos Exp $ */
/* $KAME: pfkey_dump.c,v 1.45 2003/09/08 10:14:56 itojun Exp $ */
@ -774,8 +774,10 @@ str_time(t)
for (;i < 20;) buf[i++] = ' ';
} else {
char *t0;
t0 = ctime(&t);
memcpy(buf, t0 + 4, 20);
if ((t0 = ctime(&t)) == NULL)
memset(buf, '?', 20);
else
memcpy(buf, t0 + 4, 20);
}
buf[20] = '\0';

View File

@ -1,4 +1,4 @@
/* $NetBSD: backupsa.c,v 1.9 2007/07/18 12:07:51 vanhu Exp $ */
/* $NetBSD: backupsa.c,v 1.10 2010/04/02 15:15:00 christos Exp $ */
/* $KAME: backupsa.c,v 1.16 2001/12/31 20:13:40 thorpej Exp $ */
@ -452,7 +452,7 @@ main()
struct tm tm;
time_t t;
char *buf = "Nov 24 18:22:48 1986 ";
char *p;
const char *p;
memset(&tm, 0, sizeof(tm));
p = str2tmx(buf, &tm);
@ -460,7 +460,8 @@ main()
t = mktime(&tm);
if (t == -1)
printf("mktime failed.");
p = ctime(&t);
if ((p = ctime(&t)) == NULL)
p = "?";
printf("[%s]\n", p);
exit(0);