[Bug time/33971] New: mktime()/localtime() sets tm.tm_{gmtoff,zone} according to TZDEFRULES when falling back to it
me at ziyao dot cc
sourceware-bugzilla@sourceware.org
Mon Mar 9 14:33:12 GMT 2026
https://sourceware.org/bugzilla/show_bug.cgi?id=33971
Bug ID: 33971
Summary: mktime()/localtime() sets tm.tm_{gmtoff,zone}
according to TZDEFRULES when falling back to it
Product: glibc
Version: unspecified
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: time
Assignee: unassigned at sourceware dot org
Reporter: me at ziyao dot cc
Target Milestone: ---
Created attachment 16648
--> https://sourceware.org/bugzilla/attachment.cgi?id=16648&action=edit
testing program
On a system where /usr/share/zoneinfo/posixrules is present and identical to
EST5EDT provided by tzcode, the attached test program results in weird output,
Offset from UTC time in minutes: -300
Timezone name: EST
Offset from UTC time in minutes: -300
Timezone name: EST
Offset from UTC time in minutes: -300
Timezone name: EST
while TZ is setting to "IST-2IDT". With posixrules file removed, the same
program gives out expected output,
Offset from UTC time in minutes: 120
Timezone name: IST
Offset from UTC time in minutes: 120
Timezone name: IST
Offset from UTC time in minutes: 120
Timezone name: IST
which suggests glibc to wrongly take the zone name and time offset from
TZDEFRULES.
The calculation of localtime() is done in __tzfile_compute(), and when the
epoch is after the latest known transition, __tzset_parse_tz() is called to
fill the tm structure, including tm_gmtoff and tm_name, based on tzspec,
causing the issue since tzspec is derived from TZDEFFILES.
mktime() internally invokes localtime_r(), thus is affected by the same
problem.
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the Glibc-bugs
mailing list