1
0
mirror of https://github.com/anope/anope.git synced 2026-06-12 15:44:46 +02:00

Avoid potential crashes from calling strftime on a weird value.

This commit is contained in:
Sadie Powell
2026-05-15 19:51:57 +01:00
parent 47b927d788
commit 8930cc2a92
+3 -1
View File
@@ -686,7 +686,9 @@ Anope::string Anope::strftime(time_t t, const NickCore *nc, bool short_output)
}
char buf[256];
strftime(buf, sizeof(buf), "%c", (nc ? localtime(&t) : gmtime(&t)));
const auto *ts = nc ? localtime(&t) : gmtime(&t);
if (!ts || !strftime(buf, sizeof(buf), "%c", ts))
snprintf(buf, sizeof(buf), "(invalid timestamp)");
if (nc)
{