Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 5 Jan 1999 17:29:07 +0900 (JST)
From:      ishisone@sra.co.jp
To:        FreeBSD-gnats-submit@FreeBSD.ORG
Subject:   bin/9323: year 2000 problem with /usr/bin/touch
Message-ID:  <199901050829.RAA29543@srapc459.sra.co.jp>

next in thread | raw e-mail | index | archive | help


>Number:         9323
>Category:       bin
>Synopsis:       year 2000 problem with /usr/bin/touch
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jan  5 00:30:01 PST 1999
>Closed-Date:
>Last-Modified:
>Originator:     Makoto Ishisone
>Release:        FreeBSD 2.2.7-RELEASE i386
>Organization:
Software Research Associates, Inc.
>Environment:

>Description:

  When used in its obsolescent form (where the time is specified as the
  first argument), /usr/bin/touch doesn't treat the two-digit year
  specification correctly.  Years in the range of 00-68 should be treated
  as 2000-2068 according to the online manual, but actually they are
  treated as 1900-1968.

  Here's an excerpt from the manual's `COMPATIBILITY' section:
	If the ``YY'' letter pair is in the range 69 to 99, the year
	is set to 1969 to 1999, otherwise, the year is set in the 21st
	century.

>How-To-Repeat:

  Try following commands.  You'll find that the modification time of
  the file is 1910, not 2010.

	% touch 0101000010 /tmp/touchme
	% ls -l /tmp/touchme

>Fix:

*** touch.c.org	Fri Jul 17 16:25:26 1998
--- touch.c	Tue Jan  5 16:10:45 1999
***************
*** 260,267 ****
  	t->tm_mday = ATOI2(arg);
  	t->tm_hour = ATOI2(arg);
  	t->tm_min = ATOI2(arg);
! 	if (year)
  		t->tm_year = ATOI2(arg);
  
  	t->tm_isdst = -1;		/* Figure out DST. */
  	tvp[0].tv_sec = tvp[1].tv_sec = mktime(t);
--- 260,270 ----
  	t->tm_mday = ATOI2(arg);
  	t->tm_hour = ATOI2(arg);
  	t->tm_min = ATOI2(arg);
! 	if (year) {
  		t->tm_year = ATOI2(arg);
+ 		if (t->tm_year < 69)
+ 			t->tm_year += 100;
+ 	}
  
  	t->tm_isdst = -1;		/* Figure out DST. */
  	tvp[0].tv_sec = tvp[1].tv_sec = mktime(t);

>Release-Note:
>Audit-Trail:
>Unformatted:

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?199901050829.RAA29543>