Use gmtime_r() and localtime_r() instead of gmtime() and localtime().
This commit is contained in:
@@ -37,13 +37,13 @@ char *
|
||||
get_timestr(time_t tstamp, int log_year)
|
||||
{
|
||||
static char buf[128];
|
||||
struct tm *timeptr;
|
||||
struct tm tm;
|
||||
|
||||
if ((timeptr = localtime(&tstamp)) != NULL) {
|
||||
if (localtime_r(&tstamp, &tm) != NULL) {
|
||||
/* strftime() does not guarantee to NUL-terminate so we must check. */
|
||||
buf[sizeof(buf) - 1] = '\0';
|
||||
if (strftime(buf, sizeof(buf), log_year ? "%h %e %T %Y" : "%h %e %T",
|
||||
timeptr) != 0 && buf[sizeof(buf) - 1] == '\0')
|
||||
&tm) != 0 && buf[sizeof(buf) - 1] == '\0')
|
||||
return buf;
|
||||
}
|
||||
return NULL;
|
||||
|
Reference in New Issue
Block a user