public inbox for gnats-prs@sourceware.org
help / color / mirror / Atom feed
From: Lars.Henriksen@netman.dk
To: pdm-gnats@zamazal.org,gnats-prs@gnu.org,bug-gnats@gnu.org
Subject: gnats/414: Wrong dates in PRs if no %z support in strftime(3)
Date: Thu, 12 Sep 2002 07:19:00 -0000	[thread overview]
Message-ID: <E17pUnH-0003o4-00@fencepost.gnu.org> (raw)

>Number:         414
>Category:       gnats
>Synopsis:       Wrong dates in PRs if no %z support in strftime(3)
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Sep 12 10:18:07 -0400 2002
>Originator:     Lars Henriksen
>Release:        4.0-beta1
>Organization:

>Environment:
Tru64
>Description:
On systems where strftime(3) does not support the format
code %z (numeric GMT offset), the dates in PRs are not correct if the local timezone is different from GMT.

The cause is a bug in gnats_strftime(). The problem is the
brokentime pointer passed to gnats_strftime(). It points to
static data that may be overwritten by calls to (among others) gmtime().

Exactly this happens in the routine minutes_gmt_offset(),
whereupon the now invalid brokentime pointer is passed on
to strftime().

Patch supplied.
>How-To-Repeat:

>Fix:
Index: misc.c
===================================================================
RCS file: /cvsroot/gnats/gnats/gnats/misc.c,v
retrieving revision 1.36
diff -u -r1.36 misc.c
--- misc.c      6 Jan 2002 16:13:20 -0000       1.36
+++ misc.c      12 Sep 2002 14:16:12 -0000
@@ -568,6 +568,11 @@
       char *fixed_template = (char*)xmalloc (strlen(template)+FORMAT_PADDING);
       const char *in = template;
       char *out = fixed_template;
+      /* Because brokentime points to static data (allocated
+       * by localtime()), it cannot be passed to a subroutine
+       * and then later be relied on to point to the same data. */
+      struct tm btime = *brokentime;
+      int result;
      
       while (*in != '\0')
        {
@@ -602,12 +607,9 @@
            }
        }
       *out = '\0';
-    
-      {
-       int result = strftime (s, size, fixed_template, brokentime);
-       free (fixed_template);
-       return result;
-      }
+      result = strftime (s, size, fixed_template, &btime);
+      free (fixed_template);
+      return result;
     }
 }
>Unformatted:
 


_______________________________________________
Gnats-prs mailing list
Gnats-prs@gnu.org
http://mail.gnu.org/mailman/listinfo/gnats-prs


                 reply	other threads:[~2002-09-12 14:19 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E17pUnH-0003o4-00@fencepost.gnu.org \
    --to=lars.henriksen@netman.dk \
    --cc=bug-gnats@gnu.org \
    --cc=gnats-prs@gnu.org \
    --cc=pdm-gnats@zamazal.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).