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:
+1
-5
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user