From 79522dc35675c189a69f3c11b9d557e3714f8bb7 Mon Sep 17 00:00:00 2001 From: Maschell Date: Tue, 6 Sep 2022 12:11:59 +0200 Subject: [PATCH] Fix displaying files/dirs with a broken date in some ftp clients --- src/ftp.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/ftp.c b/src/ftp.c index 1000561..6993588 100644 --- a/src/ftp.c +++ b/src/ftp.c @@ -444,6 +444,11 @@ static int32_t send_list(int32_t data_socket, DIR_P *iter) { size = 0; } + // if the date is past 2040-01-01 then use the current date instead. + if (mtime > 0x2208985200L) { + mtime = time(0); + } + char timestamp[13]; strftime(timestamp, sizeof(timestamp), "%b %d %Y", localtime(&mtime)); snprintf(line, sizeof(line), "%c%s%s%s%s%s%s%s%s%s 1 0 0 %10llu %s %s\r\n", (dirent->d_type & DT_DIR) ? 'd' : '-',