www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2017/05/07/08:56:03

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp AT delorie DOT com
Message-ID: <590F19F6.5070400@gmx.de>
Date: Sun, 07 May 2017 14:58:30 +0200
From: "Juan Manuel Guerrero (juan DOT guerrero AT gmx DOT de) [via djgpp AT delorie DOT com]" <djgpp AT delorie DOT com>
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.2.13) Gecko/20101206 SUSE/3.1.7 Thunderbird/3.1.7
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Re: Bug in timestamp arithmetic
References: <6c031262-a53d-4ede-925d-ef279a2e1286 AT googlegroups DOT com> <590CCAE9 DOT 3090904 AT gmx DOT de> <c896b052-d55e-454d-9cb5-89d2b446b247 AT googlegroups DOT com>
In-Reply-To: <c896b052-d55e-454d-9cb5-89d2b446b247@googlegroups.com>
X-Provags-ID: V03:K0:bAOOIDUbXMfw5BlvhhG9WHN/4sOI9+hjHhzyeorAiL6HIFTLcqd
9torFpiiF6d+TL46fvSj4SM9ghrxVN+IQt4xbIQrs2VQx545VThlhe12CCbUpxiYGsjuvqr
htl2oezNLrsaEpYWI5YEDkFckXSfLSgKlewkMgYRorngtVrwIVIy6ciZD2MpqUnf7MwbWmb
EZeJhfKaATYwa+e9gU6Qg==
X-UI-Out-Filterresults: notjunk:1;V01:K0:+qe4kKV3lK4=:Hiyf0cDrHjwO7G9S8G4uGP
Tujxcic//FWXnKj0GNHeXa7Lrdty1ohEBZFzpOKV6QWy7acu3T1r8CmocxoQC7U+odzbGjAz+
sJvk0ANQXA2VrBKRzNWWWmzhjAb6JbToYSQ/ocjhkeELPrCfQTYzw/Ng/ztRnyrrY2WcsJTmY
WTSWfj3OcE9ngmVqvy1gjhUouQAc3g5VIxDINkE7MHOzKTElwn45LNKHIst9n/vvLzi7QUFtI
gj0hT7uQRSwN63zzF1X9Fn9s4/5NLkL82lzrdRTPmTHHpxRaVQb76apwyOp0/lTJP288bpnAN
T186Yn2/gOcW6p3c/XlAcZoagbcUz2mzqyl0B2BH1Eekca2GpK6NRvRloVu9qx8/9dSO8l3PM
CON4F6m1atNmjkG2jwKuqTsJh2qTmwdqw8jA4vjJsWKJ1Lpl5r7r6069sJJS4h9zyR+qvxrgF
xujzmj5TMXqkzv527iZDlNi1slRL3MWSHpT10TcSLrarGFvACOiuPwIk8Lmk4WXty+ntAmrTu
p2ot9pNojc2NGIdxcJiLdNL5eGOnjHzpu/FpjAbtUJEdcc66bjF9lHyV/qHBt+saOtXSkO565
jJnwKiJqNFdiBzAGRHNdWt6Q5qK/ECHiq1bpF8iJeYNZG6ILQ2TOgg0QBiYv8eDCxtjUpFRHo
MF9zULeY8nkrKOM3z2x1l9wQ840YKZAHH9kLjjz+TsYDJ9VC0YLpRGnuvd8lv/6nnTqS0KEmN
ysJNPz6b4gkxgCsdyr7AlVrXA6SN7CyOKWYFcneW3s7svV9XkwobLp+CGTfm7U5p0IoUV0AAB
QClSI+1
Reply-To: djgpp AT delorie DOT com

Am 07.05.2017 09:09, schrieb Arrigo Marchiori (ardovm AT yahoo DOT it) [via djgpp AT delorie DOT com]:
> Hello Juan Manue, and thank your for your quick reply.
>
> I would like to add a note:
>
> Il giorno venerdì 5 maggio 2017 20:54:20 UTC+2, Juan Manuel Guerrero ha scritto:
>> Am 05.05.2017 15:27, schrieb Arrigo Marchiori:
>>> Dear All,
>>>
>>> I am writing here to report a bug, as I could not do it through the delorie.com web site.
> [...]
>> I also have usually neither TZ set nor djtzn205 installed and can verify the
>> bug described by the poster.  An inspection of ctime.c from the repository
>> shows that the implementation has the different bugs described in the post
>> leading to random timestamp around 1969-12-24 for my installation.
>> IMO, the fix proposed is correct and it solves the problems as explained.
>
> I understood from the comments in DJGPP's ctime.c that the source is from BSD. Therefore, I consulted the correspondant file from the FreeBSD source code, that is contrib/tzcode/localtime.c :
> https://svnweb.freebsd.org/base/stable/9/contrib/tzcode/stdtime/localtime.c?view=markup
>
> In that file:
>   - the stdoffset variable is set explicitly to zero (second modification in the patch) and
>   - the defaulttype attribute is not defined, but its value is calculated every time.
>
> Thank you and best regards,


The file seems to have been added in 1995 to the DJGPP repository and served
as development base for DJGPP/DOS specific changes.  Probably no one has
checked for newer BSD versions of that file to check if they fix some bugs.
I have committed the patch below to the DJGPP repository.

Regards,
Juan M. Guerrero


djgpp/src/libc/ansi/time/ctime.c: Bug in timestamp arithmetic fixed.  Reported and fixed by Arrigo Marchiori <ardovm AT yahoo DOT it>.



Index: djgpp/src/docs/kb/wc206.txi
===================================================================
RCS file: /cvs/djgpp/djgpp/src/docs/kb/wc206.txi,v
retrieving revision 1.4
diff -U 5 -r1.4 wc206.txi
--- djgpp/src/docs/kb/wc206.txi	30 Apr 2017 08:03:04 -0000	1.4
+++ djgpp/src/docs/kb/wc206.txi	7 May 2017 12:42:45 -0000
@@ -1,10 +1,14 @@
  @node Changes in 2.06, , Changes in 2.05, What Changed
  @section Changes in 2.06

  Here is a list of changes from DJGPP V2.05 to DJGPP V2.06

+@findex ctime AT r{, fixed wrong return value of @code{ctime(0)}}
+@findex ctime_r AT r{, fixed wrong return value of @code{ctime_r(0)}}
+A call of @code{ctime(0)} or @code{ctime_r(0)} now returns the correct value.
+
  @cindex dxe3gen and extended coff relocations
  dxe3gen now handles extended coff relocations (more than 65535 relocs.)

  @cindex Update of DXE linker script
  The dxe linker script, dxe.ld, now handles @code{.gnu.linkonce.b.*} and
Index: djgpp/src/libc/ansi/time/ctime.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/ansi/time/ctime.c,v
retrieving revision 1.12
diff -U 5 -r1.12 ctime.c
--- djgpp/src/libc/ansi/time/ctime.c	19 Apr 2014 21:50:30 -0000	1.12
+++ djgpp/src/libc/ansi/time/ctime.c	7 May 2017 12:42:46 -0000
@@ -1,5 +1,6 @@
+/* Copyright (C) 2017 DJ Delorie, see COPYING.DJ for details */
  /* Copyright (C) 2013 DJ Delorie, see COPYING.DJ for details */
  /* Copyright (C) 2005 DJ Delorie, see COPYING.DJ for details */
  /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
  /* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */
  /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
@@ -360,11 +361,11 @@
      if (strcmp(base, "posixrules"))
        return -1;

      /* 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
    {
      nread = read(fid, buf, sizeof buf);
      if (close(fid) != 0 || nread < (int)sizeof *tzhp)
@@ -942,10 +943,11 @@
    {
      stdlen = strlen(name);     /* length of standard zone name */
      name += stdlen;
      if (stdlen >= sizeof sp->chars)
        stdlen = (sizeof sp->chars) - 1;
+    stdoffset = 0;
    }
    else
    {
      if (*name == '<')
      {
@@ -1154,10 +1156,11 @@
      sp->typecnt = 1;             /* only standard time */
      sp->timecnt = 0;
      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)
      sp->charcnt += dstlen + 1;
    if (sp->charcnt > (int)sizeof sp->chars)

- Raw text -


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