aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2025-07-21 17:56:42 +0200
committerMarkus Uhlin <markus@nifty-networks.net>2025-07-21 17:56:42 +0200
commit94c9f6529e5d00c4e0dca818c02d38eaf5ac2d03 (patch)
treece70e1374c64375c692d203018400140378f9f51
parent21cf190c5c4a5048dd21a643f1571e699328af60 (diff)
Replaced non-reentrant functions with their corresponding thread safe version
-rw-r--r--FICS/utils.c24
1 files changed, 18 insertions, 6 deletions
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);
}
/*