commit 5a3df2f6bd2e9a40be8774d111988b2265c27f3e from: Markus Uhlin date: Sat Mar 7 22:34:48 2026 UTC strtime: check the return value of strftime() commit - a83a95e285273ee2cb8ab3cec810fbfbc435354d commit + 5a3df2f6bd2e9a40be8774d111988b2265c27f3e blob - 2399a035ce10f603fa2867e9bdfb0ce1abea66f6 blob + 20aae1a513a4df3d562526baeeeaf1175cac0bff --- FICS/utils.c +++ 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 *