1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-06 22:43:12 +02:00

Update short_date function to avoid crash if year > 9999 (#174)

This commit is contained in:
alicetries
2021-12-19 09:29:20 +00:00
committed by GitHub
parent 9e7d4b0122
commit b3c191fc23
+1 -5
View File
@@ -153,7 +153,6 @@ const char *long_date(time_t clock)
const char *short_date(time_t ts, char *buf)
{
struct tm *t = gmtime(&ts);
char *timestr;
static char retbuf[128];
if (!buf)
@@ -163,12 +162,9 @@ const char *short_date(time_t ts, char *buf)
if (!t)
return NULL;
timestr = asctime(t);
if (!timestr)
if (!strftime(buf, 128, "%a %b %d %H:%M:%S %Y", t))
return NULL;
strlcpy(buf, timestr, 128);
stripcrlf(buf);
return buf;
}