mirror of
https://github.com/anope/anope.git
synced 2026-06-12 17:24:49 +02:00
Avoid potential crashes from calling strftime on a weird value.
This commit is contained in:
+3
-1
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user