diff options
author | Markus Uhlin <markus@nifty-networks.net> | 2025-07-24 02:04:41 +0200 |
---|---|---|
committer | Markus Uhlin <markus@nifty-networks.net> | 2025-07-24 02:04:41 +0200 |
commit | a8cff293e630ec5c8d9e39b87fb38407c8e8c690 (patch) | |
tree | ddd8e79445fcbfabd8b3c51718bea9dc0a6634c0 | |
parent | c7cde29d436eeac3dd88f8fa458088a56ea3f11e (diff) |
com_stats_rating: fixed use of potentially dangerous function
-rw-r--r-- | FICS/comproc.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/FICS/comproc.c b/FICS/comproc.c index b377cc8..b3c05a3 100644 --- a/FICS/comproc.c +++ b/FICS/comproc.c @@ -389,11 +389,18 @@ com_stats_rating(char *hdr, statistics *stats, char *dest, const size_t dsize) stats->num); if (stats->whenbest) { + struct tm res = {0}; + snprintf(tmp, sizeof tmp, " %d", stats->best); strlcat(dest, tmp, dsize); - strftime(tmp, sizeof tmp, " (%d-%b-%y)", - localtime((time_t *) &stats->whenbest)); - strlcat(dest, tmp, dsize); + + errno = 0; + + if (localtime_r(&stats->whenbest, &res) != NULL) { + if (strftime(tmp, sizeof tmp, " (%d-%b-%y)", &res) != 0) + strlcat(dest, tmp, dsize); + } else + warn("%s: localtime_r", __func__); } if (strlcat(dest, "\n", dsize) >= dsize) { |