From 8998af28a197babbeaa5ae828f1229e499b193c1 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Tue, 2 Dec 2025 14:58:10 -0500 Subject: alf: Use 0 datestamp if year out of range; unalf: Display 0 datestamps as . --- src/listalf.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/listalf.c') diff --git a/src/listalf.c b/src/listalf.c index 34078e5..33b2bfe 100644 --- a/src/listalf.c +++ b/src/listalf.c @@ -50,14 +50,16 @@ void format_msdos_date(char *buf) { /* year actually ranges 1980 to 2107... */ year = (d >> 9) + 1980; - /* valid months range 1 to 12. values 0, 13, 14, 15 are possible - but invalid (print as ???) */ + /* valid months range 1 to 12 */ month = (d >> 5) & 0x0f; - /* valid day range is 1 to 31. 0 is invalid, print as-is. */ + /* valid day range is 1 to 31. 0 is invalid. */ day = d & 0x1f; - snprintf(buf, 12, "%2d %3s %04d", day, monthnames[month], year); + if(day == 0 || month == 0 || month > 12) + strncpy(buf, "", 12); + else + snprintf(buf, 12, "%2d %3s %04d", day, monthnames[month], year); } /* small files may be "compressed" larger than the original, so this -- cgit v1.2.3