From b3c191fc23356d9bb499fa3ef0ff728b822f4c4c Mon Sep 17 00:00:00 2001 From: alicetries <92898519+alicetries@users.noreply.github.com> Date: Sun, 19 Dec 2021 09:29:20 +0000 Subject: [PATCH] Update short_date function to avoid crash if year > 9999 (#174) --- src/misc.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/misc.c b/src/misc.c index b8e835d8f..27c4f3631 100644 --- a/src/misc.c +++ b/src/misc.c @@ -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; }