From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7074 invoked from network); 12 Sep 2002 14:19:06 -0000 Received: from unknown (HELO monty-python.gnu.org) (199.232.76.173) by sources.redhat.com with SMTP; 12 Sep 2002 14:19:06 -0000 Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 17pUoB-0005TJ-00; Thu, 12 Sep 2002 10:19:03 -0400 Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 17pUnK-0005Qo-00 for gnats-prs@gnu.org; Thu, 12 Sep 2002 10:18:10 -0400 Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 17pUnI-0005QR-00 for gnats-prs@gnu.org; Thu, 12 Sep 2002 10:18:09 -0400 Received: from fencepost.gnu.org ([199.232.76.164]) by monty-python.gnu.org with esmtp (Exim 4.10) id 17pUnI-0005QL-00; Thu, 12 Sep 2002 10:18:08 -0400 Received: from gnats by fencepost.gnu.org with local (Exim 4.10) id 17pUnH-0003o4-00; Thu, 12 Sep 2002 10:18:07 -0400 From: Lars.Henriksen@netman.dk To: pdm-gnats@zamazal.org,gnats-prs@gnu.org,bug-gnats@gnu.org Reply-To: Lars.Henriksen@netman.dk Subject: gnats/414: Wrong dates in PRs if no %z support in strftime(3) Message-Id: Sender: gnats-prs-admin@gnu.org Errors-To: gnats-prs-admin@gnu.org X-BeenThere: gnats-prs@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Copies of bug tracking system messages List-Archive: Date: Thu, 12 Sep 2002 07:19:00 -0000 X-SW-Source: 2002-q3/txt/msg00030.txt.bz2 >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