diff options
Diffstat (limited to 'contrib/tzcode/stdtime/asctime.c')
-rw-r--r-- | contrib/tzcode/stdtime/asctime.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/contrib/tzcode/stdtime/asctime.c b/contrib/tzcode/stdtime/asctime.c index 30606f1..be865fb 100644 --- a/contrib/tzcode/stdtime/asctime.c +++ b/contrib/tzcode/stdtime/asctime.c @@ -12,7 +12,7 @@ #include <sys/cdefs.h> #ifndef lint #ifndef NOID -static char elsieid[] __unused = "@(#)asctime.c 8.2"; +static char elsieid[] __unused = "@(#)asctime.c 8.5"; #endif /* !defined NOID */ #endif /* !defined lint */ __FBSDID("$FreeBSD$"); @@ -95,6 +95,10 @@ char * buf; char year[INT_STRLEN_MAXIMUM(int) + 2]; char result[MAX_ASCTIME_BUF_SIZE]; + if (timeptr == NULL) { + errno = EINVAL; + return strcpy(buf, "??? ??? ?? ??:??:?? ????\n"); + } if (timeptr->tm_wday < 0 || timeptr->tm_wday >= DAYSPERWEEK) wn = "???"; else wn = wday_name[timeptr->tm_wday]; @@ -117,10 +121,9 @@ char * buf; timeptr->tm_mday, timeptr->tm_hour, timeptr->tm_min, timeptr->tm_sec, year); - if (strlen(result) < STD_ASCTIME_BUF_SIZE || buf == buf_asctime) { - (void) strcpy(buf, result); - return buf; - } else { + if (strlen(result) < STD_ASCTIME_BUF_SIZE || buf == buf_asctime) + return strcpy(buf, result); + else { #ifdef EOVERFLOW errno = EOVERFLOW; #else /* !defined EOVERFLOW */ |