From 94c9f6529e5d00c4e0dca818c02d38eaf5ac2d03 Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Mon, 21 Jul 2025 17:56:42 +0200 Subject: Replaced non-reentrant functions with their corresponding thread safe version --- FICS/utils.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'FICS/utils.c') diff --git a/FICS/utils.c b/FICS/utils.c index fd0a8e3..e3bb93f 100644 --- a/FICS/utils.c +++ b/FICS/utils.c @@ -754,19 +754,31 @@ fix_time(char *old_time) } PUBLIC char * -strltime(time_t *clock) +strltime(time_t *p_clock) { - struct tm *stm = localtime(clock); + struct tm stm = {0}; - return strtime(stm); + errno = 0; + + if (localtime_r(p_clock, &stm) == NULL) { + warn("%s: localtime_r", __func__); + memset(&stm, 0, sizeof stm); + } + return strtime(&stm); } PUBLIC char * -strgtime(time_t *clock) +strgtime(time_t *p_clock) { - struct tm *stm = gmtime(clock); + struct tm stm = {0}; - return strtime(stm); + errno = 0; + + if (gmtime_r(p_clock, &stm) == NULL) { + warn("%s: gmtime_r", __func__); + memset(&stm, 0, sizeof stm); + } + return strtime(&stm); } /* -- cgit v1.2.3