From 190df198a4e2c10f80f705bb3488c09bb9a453b3 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 9 Nov 2014 22:31:30 +0000 Subject: [PATCH] output: prefer thread safe function localtime_r() While the dhcpd-pools might not be threading there is no reason why software should use worse function when always correct alternative is equally easy to use. Signed-off-by: Sami Kerola --- src/output.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/output.c b/src/output.c index e713056..dc79bab 100644 --- a/src/output.c +++ b/src/output.c @@ -458,16 +458,16 @@ int output_json(void) static void html_header(FILE *restrict f) { char outstr[200]; - struct tm *tmp; + struct tm *tmp, result; struct stat statbuf; stat(config.dhcpdlease_file, &statbuf); - tmp = localtime(&statbuf.st_mtime); + tmp = localtime_r(&statbuf.st_mtime, &result); if (tmp == NULL) { err(EXIT_FAILURE, "html_header: localtime"); } - if (strftime(outstr, sizeof(outstr), nl_langinfo(D_T_FMT), tmp) == 0) { + if (strftime(outstr, sizeof(outstr), nl_langinfo(D_T_FMT), &result) == 0) { errx(EXIT_FAILURE, "html_header: strftime returned 0"); }