public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/13401] New: calling localtime() or mktime() with a time far in the past corrupts cached timezone info
@ 2011-11-11  0:08 pitrou at free dot fr
  2011-11-11 11:36 ` [Bug libc/13401] " rosslagerwall at gmail dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: pitrou at free dot fr @ 2011-11-11  0:08 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=13401

             Bug #: 13401
           Summary: calling localtime() or mktime() with a time far in the
                    past corrupts cached timezone info
           Product: glibc
           Version: 2.12
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper.fsp@gmail.com
        ReportedBy: pitrou@free.fr
    Classification: Unclassified


See the following snippet:

#include <time.h>
#include <stdlib.h>

int main() {
    time_t t;
    struct tm tmp;
    char str[200];

    t = time(NULL);
    tmp = *gmtime(&t);
    tmp.tm_gmtoff = 0;
    tmp.tm_zone = NULL;

    strftime(str, sizeof(str), "%Z", &tmp);
    puts(str);

    t = -2461446500;
    localtime(&t);

    t = time(NULL);
    tmp = *gmtime(&t);
    tmp.tm_gmtoff = 0;
    tmp.tm_zone = NULL;

    strftime(str, sizeof(str), "%Z", &tmp);
    puts(str);

    return 0;
}


Output here is:
CET
PMT

After a bit of digging, it seems the external variable "tzname" gets (wrongly)
mutated by the localtime() call. The "%Z" format specifier just reuses that
info.

This issue got reproduced on several distributions, see
http://bugs.python.org/issue13309

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-06-27 11:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-11  0:08 [Bug libc/13401] New: calling localtime() or mktime() with a time far in the past corrupts cached timezone info pitrou at free dot fr
2011-11-11 11:36 ` [Bug libc/13401] " rosslagerwall at gmail dot com
2011-11-21 13:11 ` schwab@linux-m68k.org
2011-11-21 15:02 ` pitrou at free dot fr
2014-06-27 11:37 ` fweimer at redhat dot com

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).