From 43cd776d7dc8ac573262f8459edeb1c1f5f3cd09 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Thu, 7 Mar 2024 16:18:32 -0500 Subject: xtime: Call tzset() from main() instead of lazily POSIX specifies[1] that If a thread accesses tzname, daylight, or timezone directly while another thread is in a call to tzset(), or to any function that is required or allowed to set timezone information as if by calling tzset(), the behavior is undefined. So calling it lazily from arbitrary threads is risky. [1]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/tzset.html --- src/eval.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/eval.c') diff --git a/src/eval.c b/src/eval.c index 8b71833..1711001 100644 --- a/src/eval.c +++ b/src/eval.c @@ -730,7 +730,7 @@ bool eval_fls(const struct bfs_expr *expr, struct bfs_eval *state) { time_t six_months_ago = now - 6 * 30 * 24 * 60 * 60; time_t tomorrow = now + 24 * 60 * 60; struct tm tm; - if (xlocaltime(&time, &tm) != 0) { + if (!localtime_r(&time, &tm)) { goto error; } char time_str[256]; -- cgit v1.2.3