From owner-freebsd-bugs Mon Oct 25 3:20: 6 1999 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 2A37215104 for ; Mon, 25 Oct 1999 03:20:03 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id DAA84536; Mon, 25 Oct 1999 03:20:02 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Date: Mon, 25 Oct 1999 03:20:02 -0700 (PDT) Message-Id: <199910251020.DAA84536@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Mike Pritchard Subject: Re: misc/14511: chapss Y2K problem Reply-To: Mike Pritchard Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org The following reply was made to PR misc/14511; it has been noted by GNATS. From: Mike Pritchard To: kondo@ysyslab.co.jp Cc: freebsd-gnats-submit@FreeBSD.ORG Subject: Re: misc/14511: chapss Y2K problem Date: Mon, 25 Oct 1999 05:12:06 -0500 On Mon, Oct 25, 1999 at 12:41:11AM -0700, kondo@ysyslab.co.jp wrote: > >Synopsis: chapss Y2K problem > chpass expire date (year ploblem) > "-e Dec 6 99" is OK. > "-e Dec 6 00" is error. > "-e Dec 6 01" is OK. The following patch fixes the problem, but I noticed that the commit that broke this advertises that it supports single digit years in the range 69 - 68, meaning 1968 - 2068. This doesn't work. chpass fails if you try to set a date beyond Jan 18, 2038. I think the call to mktime() fails for dates beyond that, because that is the last date that can be stored in one of our time_t variables (someone correct me if I'm wrong). I also noticed that the "-e" flag isn't documented in the man page. If no one else steps up and commits a fix, I'll do it next time I have some spare time. I only took a look at this because I fixed/rewrote some of the routine that handles password change/expiration dates several years ago, and I was curious to see if it was my change that messed it up. It might be possible for chpass to incorrectly set the expiration year to 2000 if atoi returns zero due to the input string being garbled. The atot routine in chpass should probably be changed to call strtol() directly and test the return values to see if it was given a valid string of all digits. That was what the previous !year check was for, but the two digit year change messed that up. -Mike Index: util.c =================================================================== RCS file: /shared/ncvs/src/usr.bin/chpass/util.c,v retrieving revision 1.8 diff -u -r1.8 util.c --- util.c 1999/08/28 00:59:39 1.8 +++ util.c 1999/10/25 09:48:54 @@ -113,7 +113,7 @@ if (!(t = strtok((char *)NULL, " \t,")) || !isdigit(*t)) goto bad; year = atoi(t); - if (day < 1 || day > 31 || month < 1 || month > 12 || !year) + if (day < 1 || day > 31 || month < 1 || month > 12) goto bad; /* Allow two digit years 1969-2068 */ if (year < 69) -- Mike Pritchard mpp@FreeBSD.org or mpp@mpp.pro-ns.net To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message