🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #17979

There are year 2000 problems in INN 1.5.1

#17979
From: Della Lu
Date: Sat, 24 May 1997 00:00
167 lines
4778 bytes
After looking at the Year 2000 problems of INN 1.4 unoff 4 I looked
at INN 1.5.1 and found the same problems. These problems mean that
NEWNEWS and NEWGROUPS will not get new news or new groups created after
23:59:59 12/31/1999. Articles with dates such as:

23 May 97 19:25:45 GMT

will also be rejected as too old. And anything that uses parsedate may
not work as expected (needs 4 digit years to work properly). The
parsedate documentation is incorrect in saying it is year 2000 safe.

This stuff needs to be fixed fairly soon.

You need to change NNTPtoGMT [nnrpd/misc.c Line 222] from:

for (seconds = 0, year += 1900, i = 1970; i < year; i++)
  seconds += DaysInYear(i);


To this if you want it to work for 98 years:

for (seconds = 0, year += year<96?2000:1900, i = 1970; i < year; i++)
  seconds += DaysInYear(i);


Or this is a permanent solution:

[Add at line 195]
time_t ltime;
struct tm *today;
int currentyear;

[Add and change at Line 222]
time(&ltime);
today = gmtime(&ltime);
currentyear=today->tm_year+1900;
year=((currentyear/100)*100)+year;
if(year-currentyear>50)
  year-=100;
else if(year-currentyear<-50)
  year+=100;
for (seconds = 0, i = 1970; i < year; i++)
  seconds += DaysInYear(i);


parsedate() will also fail due to a problem with Convert(), 
RelativeMonth() will fail very badly due to the interaction between
that Convert() problem interacting with DSTcorrect().
 
Convert() [lib/parsedate.y Line 513] should be changed from:

if (Year < 0)
  Year = -Year;
if (Year < 100)
  Year += 1900;
if (Year < EPOCH)
  Year += 100;
 
[Who knows what they were trying to do with that last line, it would
have bad side effects after 1999]

To this if you want it to work for 39 years:
 
if (Year < 0)
  Year = -Year;
if (Year < 100)
  Year += Year<96?2000:1900;
if (Year < EPOCH) /* struct tm years */
  Year += 1900;


Or this is a permanent solution:

Change line 500-534 of parsedate.y from:

static int  DaysLeap[13] = {
  0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
  };
static int  LeapYears[] = {
  1972, 1976, 1980, 1984, 1988, 1992, 1996,
  2000, 2004, 2008, 2012, 2016, 2020, 2024, 2028, 2032, 2036
  };
register int  *yp;
register int  *mp;
register time_t Julian;
register int  i;
time_t    tod;

if (Year < 0)
  Year = -Year;
if (Year < 100)
  Year += 1900;
if (Year < EPOCH)
  Year += 100;
for (mp = DaysNormal, yp = LeapYears; yp < ENDOF(LeapYears); yp++)
  if (Year == *yp) {
    mp = DaysLeap;
    break;
    }
if (Year < EPOCH || Year > END_OF_TIME
    || Month < 1 || Month > 12
    /* NOSTRICT *//* conversion from long may lose accuracy */
    || Day < 1 || Day > mp[(int)Month])
  return -1;

Julian = Day - 1 + (Year - EPOCH) * 365;
for (yp = LeapYears; yp < ENDOF(LeapYears); yp++, Julian++)
  if (Year <= *yp)
    break;
for (i = 1; i < Month; i++)
  Julian += *++mp;


[Just what was the person who wrote the leap-year handling stuff thinking?!]

Change to this:

static int  DaysLeap[13] = {
  0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
  };
register int  *mp;
register time_t Julian;
register int  i;
time_t    tod;

if (Year < 0)
  Year = -Year;
if (Year < 100)
  {
  time_t ltime;
  struct tm *today;
  int currentyear;
  time(&ltime);
  today = gmtime(&ltime);
  currentyear=today->tm_year+1900;
  Year=((currentyear/100)*100)+year;
  if(Year-currentyear>50)
    Year-=100;
  else if(Year-currentyear<-50)
    Year+=100;
  Year += Year<96?2000:1900;
  }
if (Year < EPOCH) /* struct tm years */
  Year += 1900;

mp=Year%4?DaysNormal:(Year%100?DaysLeap:(Year%400?DaysLeap:DaysNormal));

if (Year < EPOCH || Month < 1 || Month > 12
    /* NOSTRICT *//* conversion from long may lose accuracy */
    || Day < 1 || Day > mp[(int)Month])
  return -1;

Julian=Day-1;
for(i=EPOCH;i<=Year;i++)
  Julian+=i%4?365:(i%100?366:(i%400?366:365));
for (i = 1; i < Month; i++)
  Julian += *++mp;


The permanent solutions are a bit much for a once in 100 years event.

-- 
Della "will sort year 2000 problems for food" Lu


Technical Details
Message-ID: <QI9rg+RnvAE@hana.demon.co.uk>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
References: <5l5p7p$gtp$1@Mars.mcs.net>

Show Full Headers
Complete Article Headers
Message-ID: <QI9rg+RnvAE@hana.demon.co.uk>
Subject: There are year 2000 problems in INN 1.5.1
Date: Sat, 24 May 1997 00:00:00 +0000
From: Della Lu <dellalu@hana.demon.co.uk>
References: <5l5p7p$gtp$1@Mars.mcs.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
X-Deja-AN: 243580291
X-Mail2News-Path: punt-2.mail.demon.net!hana.demon.co.uk
X-Mail2News-User: news@hana.demon.co.uk
X-Read-In: news.software.nntp
Newsgroups: news.software.nntp