www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2017/05/05/09:45:11

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Received: by 10.99.1.138 with SMTP id 132mr1278806pgb.162.1493990822815;
Fri, 05 May 2017 06:27:02 -0700 (PDT)
X-Received: by 10.157.40.242 with SMTP id s105mr982965ota.5.1493990822760;
Fri, 05 May 2017 06:27:02 -0700 (PDT)
Newsgroups: comp.os.msdos.djgpp
Date: Fri, 5 May 2017 06:27:02 -0700 (PDT)
Complaints-To: groups-abuse AT google DOT com
Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=213.203.152.112;
posting-account=HmlS2woAAAB1NabPfVdCpfr99n8R6B7m
NNTP-Posting-Host: 213.203.152.112
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <6c031262-a53d-4ede-925d-ef279a2e1286@googlegroups.com>
Subject: Bug in timestamp arithmetic
From: "Arrigo Marchiori (ardovm AT yahoo DOT it) [via djgpp AT delorie DOT com]" <djgpp AT delorie DOT com>
Injection-Date: Fri, 05 May 2017 13:27:02 +0000
Bytes: 3393
Lines: 67
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id v45Dj1UK029973
Reply-To: djgpp AT delorie DOT com

Dear All,

I am writing here to report a bug, as I could not do it through the delorie.com web site.

On my system, I did not install any timezone files. libc therefore generates a ``default'' timezone. Such timezone has a random offset with respect to GMT.

The effect is that ctime(0) returns random values, such as "31 December 1969", instead of "1 January 1970".

This problem should be resolved by the patch you can find at the end of this message.

The patch must be applied to src/libc/ansi/time/ctime.c
Its effects are the following.

 - In function tzload(): the default timezone created from _posixrules_data is actually parsed. It was not, because the nread variable was not updated with its size.

 - In function tzparse(): the value for stdoffset is set to zero, if the parameter lastditch is set. Before this patch, the value of stdoffset was never assigned, and therefore the timezone received a random offset from GMT.

 - In function tzparse(): after a new default timezone was created inside sp, the `defaulttype' field was not updated. If the default data from _posixrules was loaded correctly (see first point), sp->defaulttype would be set to 1. But previous types have just been overwritten, therefore this attribute must be set to zero, i.e. to the only current type.

I hope this makes sense to you. Feel free to contact me if you need any more information on this, or if you think I can be of any help integrating it.

Best regards,


Arrigo


--- src/libc/ansi/time/ctime.c.orig	2014-04-19 20:50:30.000000000 +0200
+++ src/libc/ansi/time/ctime.c	2017-05-05 14:20:54.988023000 +0200
@@ -362,7 +362,7 @@
 
     /* We've got a built-in copy of posixrules just in case */
     memcpy(buf, _posixrules_data, sizeof(_posixrules_data));
-    i = sizeof(_posixrules_data);
+    nread = sizeof(_posixrules_data);
   }
   else
   {
@@ -944,6 +944,7 @@
     name += stdlen;
     if (stdlen >= sizeof sp->chars)
       stdlen = (sizeof sp->chars) - 1;
+    stdoffset = 0;
   }
   else
   {
@@ -1156,6 +1157,7 @@
     sp->ttis[0].tt_gmtoff = -stdoffset;
     sp->ttis[0].tt_isdst = 0;
     sp->ttis[0].tt_abbrind = 0;
+    sp->defaulttype = 0;
   }
   sp->charcnt = stdlen + 1;
   if (dstlen != 0)

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019