summaryrefslogtreecommitdiffhomepage
path: root/src/log.c
diff options
context:
space:
mode:
authorrofl0r <rofl0r@users.noreply.github.com>2020-10-19 20:26:12 +0100
committerrofl0r <rofl0r@users.noreply.github.com>2020-10-19 20:26:12 +0100
commit8ebbd50cb2d5c20163272fe081fc58329fd896bd (patch)
treeece9dfd0217945b6696bf3ae5602c6b2306be6c7 /src/log.c
parent732bdd0f5678cabae32849e0dac1c4f8478ca33c (diff)
log: replace non-mt-safe localtime() with localtime_r()
Diffstat (limited to 'src/log.c')
-rw-r--r--src/log.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/log.c b/src/log.c
index 516fcd8..14fc3fe 100644
--- a/src/log.c
+++ b/src/log.c
@@ -109,6 +109,7 @@ void log_message (int level, const char *fmt, ...)
{
va_list args;
struct timespec nowtime;
+ struct tm tm_buf;
char time_string[TIME_LENGTH];
char str[STRING_LENGTH];
@@ -177,7 +178,7 @@ void log_message (int level, const char *fmt, ...)
clock_gettime(CLOCK_REALTIME, &nowtime);
/* Format is month day hour:minute:second (24 time) */
strftime (time_string, TIME_LENGTH, "%b %d %H:%M:%S",
- localtime (&nowtime.tv_sec));
+ localtime_r (&nowtime.tv_sec, &tm_buf));
snprintf (str, STRING_LENGTH, "%-9s %s.%03lu [%ld]: ",
syslog_level[level], time_string,