[File] [PATCH] print.c: initialize timezone data for localtime_r()

joe.slater at windriver.com joe.slater at windriver.com
Tue Aug 8 00:03:34 UTC 2023


From: Joe Slater <joe.slater at windriver.com>

The man page for localtime() points out that while it acts
like tzset() has been called, localtime_r() might not.  We
have a local version of localtime_r() that avoids this, but
we do not compile it.

Signed-off-by: Joe Slater <joe.slater at windriver.com>
---
 src/print.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/print.c b/src/print.c
index 18f42a05..b1de4908 100644
--- a/src/print.c
+++ b/src/print.c
@@ -286,6 +286,7 @@ file_fmtdatetime(char *buf, size_t bsize, uint64_t v, int flags)
 	}
 
 	if (flags & FILE_T_LOCAL) {
+		tzset();
 		tm = localtime_r(&t, &tmz);
 	} else {
 		tm = gmtime_r(&t, &tmz);
-- 
2.35.5



More information about the File mailing list