In logger.c:klog_vsyslog(), check the return value of localtime(). In
ldap_principal2.c:getstringtime(), check the strftime() result and
don't leak strtime on error.
time_t now;
#ifdef HAVE_STRFTIME
size_t soff;
+ struct tm *tm;
#else
char *r;
#endif
/*
* Format the date: mon dd hh:mm:ss
*/
- soff = strftime(outbuf, sizeof(outbuf), "%b %d %H:%M:%S", localtime(&now));
+ tm = localtime(&now);
+ if (tm == NULL)
+ return(-1);
+ soff = strftime(outbuf, sizeof(outbuf), "%b %d %H:%M:%S", tm);
if (soff > 0)
cp += soff;
else
char *strtime=NULL;
time_t posixtime = ts2tt(epochtime);
- strtime = calloc (50, 1);
- if (strtime == NULL)
- return NULL;
-
if (gmtime_r(&posixtime, &tme) == NULL)
return NULL;
- strftime(strtime, 50, "%Y%m%d%H%M%SZ", &tme);
+ strtime = calloc(50, 1);
+ if (strtime == NULL)
+ return NULL;
+ if (strftime(strtime, 50, "%Y%m%d%H%M%SZ", &tme) == 0) {
+ free(strtime);
+ return NULL;
+ }
return strtime;
}