diff options
Diffstat (limited to 'FICS/comproc.c')
-rw-r--r-- | FICS/comproc.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/FICS/comproc.c b/FICS/comproc.c index b3c05a3..a7a5ea1 100644 --- a/FICS/comproc.c +++ b/FICS/comproc.c @@ -45,6 +45,8 @@ array index read/write. Markus Uhlin 25/07/21 com_who: fixed multiplication result converted to larger type. + Markus Uhlin 25/07/24 Fixed use of potentially + dangerous functions. */ #include "stdinclude.h" @@ -53,6 +55,7 @@ #include <sys/resource.h> #include <err.h> +#include <errno.h> #include "board.h" #include "command.h" @@ -590,9 +593,14 @@ com_stats(int p, param_list param) if (connected && parray[p1].registered && (p == p1 || parray[p].adminLevel > 0)) { - char *timeToStr = ctime((time_t *) &parray[p1].timeOfReg); + char timeToStr[30] = { '\0' }; + + errno = 0; + + if (ctime_r(&parray[p1].timeOfReg, timeToStr) == NULL) + warn("%s: ctime_r", __func__); + timeToStr[strcspn(timeToStr, "\n")] = '\0'; - timeToStr[strlen(timeToStr) - 1] = '\0'; pprintf(p, "\n"); onTime = ((time(NULL) - parray[p1].logon_time) + |