From 5a3df2f6bd2e9a40be8774d111988b2265c27f3e Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Sat, 7 Mar 2026 23:34:48 +0100 Subject: strtime: check the return value of strftime() --- FICS/utils.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/FICS/utils.c b/FICS/utils.c index 2399a03..20aae1a 100644 --- a/FICS/utils.c +++ b/FICS/utils.c @@ -825,15 +825,23 @@ hms(int t, int showhour, int showseconds, int spaces) } PRIVATE char * -strtime(struct tm * stm) +strtime(struct tm *stm) { - static char tstr[100]; + static char tstr[100] = { '\0' }; + #if defined (SGI) - strftime(tstr, sizeof(tstr), "%a %b %e, %H:%M %Z", stm); + if (strftime(tstr, sizeof(tstr), "%a %b %e, %H:%M %Z", stm) == 0) { + memset(tstr, 0, sizeof(tstr)); + return &tstr[0]; + } #else - strftime(tstr, sizeof(tstr), "%a %b %e, %k:%M %Z", stm); + if (strftime(tstr, sizeof(tstr), "%a %b %e, %k:%M %Z", stm) == 0) { + memset(tstr, 0, sizeof(tstr)); + return &tstr[0]; + } #endif - return (tstr); + + return (&tstr[0]); } PUBLIC char * -- cgit v1.2.3