This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/13401] New: calling localtime() or mktime() with a time far in the past corrupts cached timezone info
- From: "pitrou at free dot fr" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: Fri, 11 Nov 2011 00:08:17 +0000
- Subject: [Bug libc/13401] New: calling localtime() or mktime() with a time far in the past corrupts cached timezone info
- Auto-submitted: auto-generated
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.