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 <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2014-11-09 22:31:30 +00:00
parent e401c2c7e6
commit 190df198a4

View file

@ -458,16 +458,16 @@ int output_json(void)
static void html_header(FILE *restrict f) static void html_header(FILE *restrict f)
{ {
char outstr[200]; char outstr[200];
struct tm *tmp; struct tm *tmp, result;
struct stat statbuf; struct stat statbuf;
stat(config.dhcpdlease_file, &statbuf); stat(config.dhcpdlease_file, &statbuf);
tmp = localtime(&statbuf.st_mtime); tmp = localtime_r(&statbuf.st_mtime, &result);
if (tmp == NULL) { if (tmp == NULL) {
err(EXIT_FAILURE, "html_header: localtime"); 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"); errx(EXIT_FAILURE, "html_header: strftime returned 0");
} }