From owner-freebsd-bugs Thu Jan 27 6: 0: 6 2000 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id 9BDBA154B2 for ; Thu, 27 Jan 2000 06:00:03 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id GAA60228; Thu, 27 Jan 2000 06:00:03 -0800 (PST) (envelope-from gnats@FreeBSD.org) Date: Thu, 27 Jan 2000 06:00:03 -0800 (PST) Message-Id: <200001271400.GAA60228@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: "Sergey N. Voronkov" Subject: Re: bin/15872: Y2k bug in at(1) Reply-To: "Sergey N. Voronkov" Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org The following reply was made to PR bin/15872; it has been noted by GNATS. From: "Sergey N. Voronkov" 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