Article delegate-en/665 of [1-5169] on the server localhost:119
  upper oldest olders older1 this newer1 newers latest
search
[Top/Up] [oldest] - [Older+chunk] - [Newer+chunk] - [newest + Check]
[Reference:<_A8116@delegate.ML_>]
Newsgroups: mail-lists.delegate-en

[DeleGate-En] Y2K considerations
21 Dec 1999 10:08:26 GMT ysato@etl.go.jp (Yutaka Sato)


------------------------------------------------------------------------------
    Y2K relevant codes in DeleGate        Dec 21, 1999 <ysato@etl.go.jp>
------------------------------------------------------------------------------
So far, only problem relevant to Y2K found in DeleGate is about CRON parameter
and was fixed in 5.9.2 (1999May12).  I think other possible problems can be
caused by the "%y" format implemented in "rary/Strftime.c" thus inspected
whole codes relevant to it.  From my inspection as follows, there are several
bugs which can cause Y2K problem, but no one seems to be serious. 

1 COMMON CODE (rary/Strftime.c)

1.1 COMMON (format data including "%y")

  char *TIMEFORM_RFC850 = "%A, %d-%b-%y %H:%M:%S %z";
  char *TIMEFORM_ymdhms = "%y%m%d%H%M%S";
  char *TIMEFORM_LS     = "%y/%m/%d %H:%M:%S";

1.2 GENERATOR (generator function based on "%y")

X) Strftime0() --- generates "100" instead of "00" for "%y" of 2000
        case 'y': ap = sprint02d(ap,tm->tm_year); break;

1.3 PARSER (parser function based on "%y")

Y) scanftime() --- recognize "00" for "%y" as 1900 instead of 2000
        case 'y':
        case 'Y': if((sp = scanint(sp,&year)) == NULL) goto EXIT;
                if( 1900 <= year ) 
                        year -= 1900;
                break;

   scanHTTPtime() -> scanftime()
    1) TIMEFORM_RFC822
   *2) TIMEFORM_RFC850
    3) TIMEFORM_ANSI_C

   scanNNTPtime() -> scanftime()
    1) TIMEFORM_RFC822
   *2) TIMEFORM_RFC850
    3) TIMEFORM_ANSI_C
    4) TIMEFORM_USENET

Z) scantime() --- recognize "00" for "%y" as 1900 instead of 2000
        tm->tm_year = 1900 < year ? (year - 1900) : year;

1.4 CONSIDERATION

Since these are miss-implementation if we regard the "%y" in DeleGate is
that in certain defact standard, they must be fixed.
Obviously the generator must simply generate "0X" for "200X".
Parsers must recognize "0X" as "200X", still recognizing "10X" as "200X"
too for safety.


2 GENERATOR CODE

There are three type of usage of date information:

  ext data -- data send to external out of DeleGate
  log data -- data recorded into local log file
  file name -- local directory/file name consists of date information

Y2K relevant codes and usage are as fllows:

a) src/enews.c:   "%H%M%S.%y%m%d"        >> ext data (default Message-ID)
b) src/httpd.c:   TIMEFORM_LS            >> ext data (directory date displayed
                                         >>           in origin HTTP)
(OPTIONAL)
c) src/log.c:      [data+user-defined]   -> file name (log file)
d) src/log.c:      "-%y%m%d%H%M%S.old"   -> file name (aged log file)
e) src/smtpgate.c: "%y%m%d-%H%M%S"       -> file name (backup spool)
f) src/smtpgate.c: ${date+user-defined}  -> file name (backup spool)
g) filters/cafe.c: "%y/%m/%d-%H:%M:%S"   >> log data (EXPIRELOG)
h) rary/sched.c:  "%w/%y:%m:%d:%H:%M:%S" >> log data (error/debug log)

(EXPERIMENTAL ... not used practically)

i) filters/expired.c: "%y%m%d/%H%M"      -> file name (fstat cache file)
j) src/gacl.c:     "%y/%m/%d-%H:%M:%S"   >> ext data (GACL user id)
k) src/gacl.c:     "%y/%m/%d-%H:%M:%S"   >> log data (GACL event log)
l) src/httplog.c:  TIMEFORM_ymdhms       >> log data (plublic log)
m) src/ssi.c:      "%d/%m/%y-%H:%M:%S"   >> ext data (flastmod, DATE_GMT)
n) src/smtp.c:     "%y%m%d"              >> ext data (MAILGATE user id)
o) src/nsh.c:  "%y/%m/%d %H:%M:%S %z %a" >> ext data (date command result)

2.1 CONSIDERATION

 These problems will be fixed with a patch to Strftime.c about X) and Y),
 or even without the fix, in these issues,
 c) seems a (maybe only) practical problem.  The problem will occur when
 user specified "[date+format]" including "%y" in LOGDIR or LOGFILE or so
 creating file like ".../100/..." instead of "../00/..".
 These built-in "%y"s can be replaced with "%Y" and also user-defined
 "%y"s, if exist, are recommented to be replaced with "%Y";


3 PARSER CODE

p) src/http[head].c: scanHTTPtime()      <- Expires: header (for expire)
q) src/http.c:     scantime()            <- If-Modified-Since / Last-Modified
r) src/nntp.c:     "%y %m %d %H %M %S"   <- NEWNEWS NEWGROUPS command
s) src/nntpgw.c:   scanNNTPtime()        <- Date: (displayed in NNTP/HTTP)

3.1 CONSIDERATION

 These problems will be fixed with a patch to Strftime.c about Z), or even
 without the fix,
 p),q),r) are scarcely problematic since these functions are expected to
 receive a year value in full "2000" format as in the current standard
 specifications.
 s) is possibly problematic but the result will not be serious.


4 FIX

Here is a patch for Strftime.c of DeleGate/6.0.6.  The next release of
DeleGate (6.0.7 and 5.9.12) will be released with this modification.

*** ../../delegate6.0.6/rary/Strftime.c	Fri Oct 29 15:44:28 1999
--- Strftime.c	Tue Dec 21 18:12:48 1999
***************
*** 274,280 ****
  		case 'S': ap = sprint02d(ap,tm->tm_sec);	break;
  		case 'U': ap = sprint02d(ap,NthWeek(tm,0));	break;
  		case 'W': ap = sprint02d(ap,NthWeek(tm,1));	break;
! 		case 'y': ap = sprint02d(ap,tm->tm_year);	break;
  
  		case 'Y':
  			sprintf(buf,"%d",tm->tm_year+1900);
--- 274,280 ----
  		case 'S': ap = sprint02d(ap,tm->tm_sec);	break;
  		case 'U': ap = sprint02d(ap,NthWeek(tm,0));	break;
  		case 'W': ap = sprint02d(ap,NthWeek(tm,1));	break;
! 		case 'y': ap = sprint02d(ap,tm->tm_year % 100);	break;
  
  		case 'Y':
  			sprintf(buf,"%d",tm->tm_year+1900);
***************
*** 362,367 ****
--- 362,369 ----
  		case 'W': sp = awordscan(sp,sym); break;
  		case 'y':
  		case 'Y': if((sp = scanint(sp,&year)) == NULL) goto EXIT;
+ 			if( 0 <= year && year < 70 )
+ 				year += 100;
  			if( 1900 <= year )
  				year -= 1900;
  			break;
***************
*** 525,530 ****
--- 527,534 ----
  	clock = -1;
  	if( ni == 7 ){
  		tm->tm_wday = wdaytoi(swday);
+ 		if( 0 <= year && year < 70 )
+ 			year += 100;
  		tm->tm_year = 1900 < year ? (year - 1900) : year;
  		tm->tm_mon  = montoi(smon);
  		tm->tm_mday = mday;
------------------------------------------------------------------------------

  admin search upper oldest olders older1 this newer1 newers latest
[Top/Up] [oldest] - [Older+chunk] - [Newer+chunk] - [newest + Check]
@_@V