Skip to content

Commit 475face

Browse files
committed
Change localtime to localtime_r to avoid future concurrency issues
1 parent 6169b65 commit 475face

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/auditd.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ static void cont_handler(struct ev_loop *loop, struct ev_signal *sig,
231231
int revents)
232232
{
233233
char buf[64];
234+
struct tm tm;
234235
mode_t u = umask(0137); // allow 0640
235236
FILE *f = fopen(state_file, "w");
236237
umask(u);
@@ -246,7 +247,7 @@ static void cont_handler(struct ev_loop *loop, struct ev_signal *sig,
246247
}
247248
fprintf(f, "audit version = %s\n", VERSION);
248249
time_t now = time(0);
249-
strftime(buf, sizeof(buf), "%x %X", localtime(&now));
250+
strftime(buf, sizeof(buf), "%x %X", localtime_r(&now, &tm));
250251
fprintf(f, "current time = %s\n", buf);
251252
fprintf(f, "process priority = %d\n", getpriority(PRIO_PROCESS, 0));
252253
write_logging_state(f);

0 commit comments

Comments
 (0)