[19935] in bugtraq

home help back first fref pref prev next nref lref last post

Re: The April Fools 2001 bug in Windows

daemon@ATHENA.MIT.EDU (Matt Scarborough)
Fri Mar 30 03:09:51 2001

Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Message-ID:  <20010329220022.11370.qmail@awcst401.netaddress.usa.net>
Date:         Thu, 29 Mar 2001 17:00:22 EST
Reply-To: Matt Scarborough <vexversa@USA.NET>
From: Matt Scarborough <vexversa@USA.NET>
To: BUGTRAQ@SECURITYFOCUS.COM
Content-Transfer-Encoding: 8bit

On Wed, 28 Mar 2001 09:14:06 -0500, "Richard M. Smith"
<rms@PRIVACYFOUNDATION.ORG> wrote:


>Applications built with certain versions of Visual C++ could
>start giving the wrong time of day starting on Sunday.  The problem
>will last for a week.

>Here is a Microsoft FAQ about the bug:
>
>   http://msdn.microsoft.com/visualc/headlines/2001.asp

Additional resource with quoted text re-ordered from
http://support.microsoft.com/support/kb/articles/Q214/6/61.ASP

Microsoft has confirmed this to be a bug in the Microsoft products
Microsoft Visual C++, 32-bit Editions, versions 4.1, 4.2, 5.0, 6.0
This bug was corrected in Visual Studio 6.0 Service Pack 3.

The bug is caused by a logic error in the C-Run-time library's cvtdate helper
function.

>Unfortunately not all applications can be corrected with a new release of
>MSVCRT.DLL.  Any applications which statically links with the Visual C++
>runtime will have to be fixed by the application vendor.  Users will
>have to download the new releases of these kinds of applications.

The following sample program reproduces the problem: 
// ----------------- start of sample program ------------------------- 
// ----------------- Code Courtesy MSFT Q214661 ------------------- 
// Compiler switches needed : none.

#include <time.h>;
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>

int main ()
{
      struct tm ltm;
      time_t tstamp = 0;

      ltm.tm_year = 90;   /* First valid year .*/ 
      ltm.tm_mon = 3;             /* April. */ 
      ltm.tm_mday = 1;    /* 1st of the month. */ 
      ltm.tm_hour = 3;    /* At 3:00 am. */ 
      ltm.tm_min = 0;
      ltm.tm_sec = 0;
      ltm.tm_wday =0;
      ltm.tm_yday = 0;

      while (ltm.tm_year <= 2005)
      {
          ltm.tm_isdst = -1;

          // mktime indirectly calls cvtdate which has the logic bug.
          tstamp = mktime(&ltm);

          /* If it's Sunday April 1st, it should also be DST */ 
          if (!ltm.tm_wday && !ltm.tm_isdst)
          {
              printf("April 01 is the first Sunday in April, %d  \ 
              -it should be DST but tm_isdst says it's \ 
              not!\n", 1900+ltm.tm_year);
              while (!ltm.tm_isdst)
              {
                  ltm.tm_mday++;
                  ltm.tm_isdst=-1;
                  tstamp = mktime(&ltm);
              }
              printf("\tDST is reported as starting on  \ 
              %d/%d/%d\n", 1+ltm.tm_mon, ltm.tm_mday, \ 
              1900+ltm.tm_year);
          
              ltm.tm_mday = 1;
          }
          
          ltm.tm_year++;
          
      }

      return 0;
  }


// ----------------- end  of sample program --------------------------- 


____________________________________________________________________
Get free email and a permanent address at http://www.amexmail.com/?A=1

home help back first fref pref prev next nref lref last post