From a1e0a0e9286fbe90ca04cda9df38e72d8d18b0c1 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 14 Jun 2006 21:36:49 +0000 Subject: r16230: Fix Klocwork #861 and others. localtime and asctime can return NULL. Ensure we check all returns correctly. Jeremy. (This used to be commit 6c61dc8ed6d84f310ef391fb7700e93ef42c4afc) --- source3/utils/net_time.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source3/utils/net_time.c') diff --git a/source3/utils/net_time.c b/source3/utils/net_time.c index 1a7116d447..f6486286a6 100644 --- a/source3/utils/net_time.c +++ b/source3/utils/net_time.c @@ -69,12 +69,15 @@ static time_t nettime(int *zone) } /* return a time as a string ready to be passed to /bin/date */ -static char *systime(time_t t) +static const char *systime(time_t t) { static fstring s; struct tm *tm; tm = localtime(&t); + if (!tm) { + return "unknown"; + } fstr_sprintf(s, "%02d%02d%02d%02d%04d.%02d", tm->tm_mon+1, tm->tm_mday, tm->tm_hour, -- cgit