Date: Thu, 27 Jan 2000 06:00:03 -0800 (PST) From: "Sergey N. Voronkov" <serg@dor.zaural.ru> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/15872: Y2k bug in at(1) Message-ID: <200001271400.GAA60228@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/15872; it has been noted by GNATS. From: "Sergey N. Voronkov" <serg@dor.zaural.ru> To: wollman@freebsd.org Cc: FreeBSD-gnats-submit@freebsd.org Subject: Re: bin/15872: Y2k bug in at(1) Date: Thu, 27 Jan 2000 18:53:59 +0500 (YEKT) Hello Nick! As a last person deeply touched /usr/src/usr.bin/at/parsetime.c, could you, please, review and apply this patch to at (PR/15872). Patch is based on OpenBSD code. Sorry, I test it only on my 3.4-STABLE system. In CURRENT may be need to make some changes in patch header. assign_date() has some bug in both versions. Serg N. Voronkov --- parsetime.c.orig Mon Aug 30 00:42:00 1999 +++ parsetime.c Thu Jan 27 18:50:48 2000 @@ -417,27 +417,28 @@ static void assign_date(struct tm *tm, long mday, long mon, long year) { - if (year > 99) { - if (year > 1899) - year -= 1900; - else - panic("garbled time"); - } else if (year != -1) { - struct tm *lt; - time_t now; - time(&now); - lt = localtime(&now); + /* + * Convert year into tm_year format (year - 1900). + */ + if (year != -1) { + if (year >= 1900) + year -= 1900; /* convert from 4 digit year */ + else if (year < 100) { + /* convert from 2 digit year */ + struct tm *lt; + time_t now; - /* - * check if the specified year is in the next century. - * allow for one year of user error as many people will - * enter n - 1 at the start of year n. - */ - if (year < (lt->tm_year % 100) - 1) - year += 100; - /* adjust for the year 2000 and beyond */ - year += lt->tm_year - (lt->tm_year % 100); + time(&now); + lt = localtime(&now); + + /* Convert to tm_year assuming current century */ + year += (lt->tm_year / 100) * 100; + + if (year == lt->tm_year - 1) year++; + else if (year < lt->tm_year) + year += 100; /* must be in next century */ + } } if (year < 0 && To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200001271400.GAA60228>