Y2K bug in NEWGROUPS

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I discovered the following millennium bug in the code that implements
the NEWGROUPS request. With the current implementation (r. 2_3_3b4) the
request with a date after 2000 will always result in an error message as
in the following example. (We request a list of all groups created after
1:01:00 h on Jan. 1st 2000).

        NEWGROUPS 000101 010100
        501 yymmdd hhmmss ["GMT"] [<distributions>]

This should generate a '231 List of newgroups follows' response. The
reason this fails is that nntp-cache interprets the date '000101' as
Jan. 1st 1900 and not as Jan. 1st 2000 as it should do according to the
RFC. The code that implements this request can be found in the file
'newgroups.c' in the function CMDnewgroups: 

        if (sscanf(args, "%*s %6s %6s %3s <%127s>", d, d+6, gmt,
dist)<2)
        /* d = "000101010100\n" */
        {
  bad:
                emitrn("501 yymmdd hhmmss [\"GMT\"] [<distributions>]");
                return FALSE;
        }
        for (i=0; i<6; i++)
                if ((t[i]=c2i(d+2*i))==-1)
                        goto bad;
        /* t[0] = 0 */
        memset(&tm, 0, sizeof tm);
        tm.tm_year = t[0];
        tm.tm_mon = t[1]-1;
        tm.tm_mday = t[2];
        tm.tm_hour = t[3];
        tm.tm_min = t[4];
        tm.tm_sec = t[5];
        if ((tim=mktime(&tm))==-1)
                goto bad;

When the struct tm is created the tm_year field gets the value 0 where
it should get the value 100. Subsequently the structure is used as an
argument for the mktime call which returns the number of seconds after
1-1-1970. Naturally this call fails which causes the errormessage.

A small change in the code solves the problem:

      if (t[0] < 50) 
            tm.tm_year = t[0] + 100;
      else
            tm.tm_year = t[0];


Marnix
---
Marnix Harssema         Building VN-216
Origin bv.              PO Box 218
TIS/Intranet Services   5600 MD Eindhoven, Netherlands
tel.: +31 40 27 85897/fax: 88729
mailto:Marnix.Harssema@nl.origin-it.com


[Index of Archives]     [Yosemite]     [Yosemite Campsites]     [Bugtraq]     [Linux]     [Trn]

Powered by Linux