To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.admin.generalOpen lugnet.admin.general in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Administrative / General / 4019
4018  |  4020
Subject: 
Re: Y2K problem with lugnet! (was Re: Help! My newsreader's downloading everything on lugnet!)
Newsgroups: 
lugnet.admin.general
Date: 
Sat, 1 Jan 2000 23:30:33 GMT
Viewed: 
995 times
  
In lugnet.admin.general, mattdm@mattdm.org (Matthew Miller) writes:
Are you using INN? I know that the newest version (2.2.something) was
released to be a fix for a _different_ problem with the NEWNEWS and
NEWGROUPS commands. If I remember right, 1.6 is the oldest version that
works. If you are running INN, it's 1.5.12.2, yeah? :)

No -- it's using C News, because it's got a much smaller memory footprint
than INN and is better suited to serving large numbers of simultaneous NNTP
connections to small numbers of groups (groups in the hundreds rather than
tens of thousands).  So far it's been a great choice.  Plus, a large part of
CNews is shell scripts, making it much easier to interface with custom
add-on components.

Anyway, I think the problem lies in a function called dtol() in the NNTP
Reference Implementation of the nntpd daemon.  Here's how it goes (with the
"#if DEBUG" directives removed in this cut & paste for readability)...


------------------------------------begin-------------------------------------
/*
* dtol -- convert date to long integer.  This is not implicitly
* local time, or any other kind of time, for that matter.  If you
* pass it a date you think is GMT, you wind up with that number of
* seconds...
*
*      Parameters:             "date_ascii" is in the form "yymmddhhmmss".
*
*      Returns:                Long integer containing number
*                              of seconds since 000000 Jan 1, 1970,
*                              and "date".  -1 on error.
*
*      Side effects:           None.
*/

#define twodigtoi(x)    (((x[0]) - '0') + (x[1] - '0')*10)
#define dysize(y)       ((y % 4 ? 365 : 366))

static  int     dmsize[12] =
    { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

long
dtol(date_ascii)
        char    *date_ascii;
{
        char    date[32], *date_str;
        char    *lhs, *rhs;
        char    temp;
        long    seconds;
        int     year, month, day, hour, mins, secs;
        int     len, i;

        len = strlen(date_ascii);
        if (len != sizeof("yymmddhhmmss")-1)
                return (-1);

        (void) strcpy(date, date_ascii);
        date_str = date;

        rhs = date_str + len - 1;
        lhs = date_str;

        for (; lhs < rhs; ++lhs, --rhs) {
                temp = *lhs;
                *lhs = *rhs;
                *rhs = temp;
                if (!isdigit(temp) || !isdigit(*lhs))
                        return (-1);
        }

        lhs = date_str;

        secs = twodigtoi(lhs);
        lhs += 2;
        mins = twodigtoi(lhs);
        lhs += 2;
        hour = twodigtoi(lhs);
        lhs += 2;
        day = twodigtoi(lhs);
        lhs += 2;
        month = twodigtoi(lhs);
        lhs += 2;
        year = twodigtoi(lhs);

        if (month < 1 || month > 12 ||
            day < 1 || day > 31 ||
            mins < 0 || mins > 59 ||
            secs < 0 || secs > 59)
                return (-1);
        if (hour == 24) {
                hour = 0;
                day++;
        }
        if (hour < 0 || hour > 23)
                return (-1);
        seconds = 0;
        year += 1900;
        for (i = 1970; i < year; i++)
                seconds += dysize(i);
        /* Leap year */
        if (dysize(year) == 366 && month >= 3)
                seconds++;
        while (--month)
                seconds += dmsize[month-1];
        seconds += day-1;
        seconds = 24 * seconds + hour;
        seconds = 60 * seconds + mins;
        seconds = 60 * seconds + secs;

        return (seconds);
}
-------------------------------------end--------------------------------------


Ideally, there should at least have been

   if (year < 1970)
      return (-1);

after the

   year += 1900;

but oh well.

To fix this, I'm thinking of changing the single line

   year += 1900;

to

   year += (year >= 70) ? 1900 : 2000;   /* Y2K bug workaround */

And the 'for' loop after that should still work fine, since 'year' will be
set to 2000 after being initially 0.

However, it's also possible that dysize() has a bug, depending on whether or
not 2000 is a leap year (I can never remember).

Here's dysize()...

------------------------------------begin-------------------------------------
#define dysize(y)       ((y % 4 ? 365 : 366))
-------------------------------------end--------------------------------------

According to 'cal', 2000 *is* a leap year, so it would appear that dysize()
is correct until 2100 (which I think isn't a leap year, right?).

I wonder why Free Agent works OK with this newsserver?  It must be using
XOVER or something instead of NEWNEWS...

--Todd


p.s.  That whole string-reversing and twodigtoi() bit there is a little
frightening, eh...?



Message has 1 Reply:
  Re: Y2K problem with lugnet! (was Re: Help! My newsreader's downloading everything on lugnet!)
 
(...) Update: Well, that fixes the NEWGROUPS command all right, but the NEWNEWS command is doing something more insidious afterwards with date strings. Still digging...old nntpd is still in place. Oddly, the NNTP Reference Implementation distro (...) (25 years ago, 2-Jan-00, to lugnet.admin.general)

Message is in Reply To:
  Re: Y2K problem with lugnet! (was Re: Help! My newsreader's downloading everything on lugnet!)
 
(...) Whoo hoo. For what it's worth, it's the second one I've come across today -- I "fixed" (ie reset the date in the BIOS) a POS system at a store in Northampton. Felt pretty proud of myself. :) (...) Are you using INN? I know that the newest (...) (25 years ago, 1-Jan-00, to lugnet.admin.general)

40 Messages in This Thread:












Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR