Overview
| Artifact ID: | b0347cdfb9ff4f3edc429cf18958e4906cedbbddc06de553ddadd92060a82ed4 |
|---|---|
| Ticket: | 832d098fdfec8f004cf1c8e8836f7c335da12d54
Clock reads TZif version 3 and 4 zoneinfo files as version 1 - zones with an extended footer lose all their transitions |
| User & Date: | kenneth.kienle on 2026-09-03 19:46:50 |
Changes
- assignee changed to: "nobody"
- closer changed to: "nobody"
- cmimetype changed to: "text/x-markdown"
- comment changed to:
`library/clock.tcl`'s `ReadZoneinfoFile` selects the 64-bit data block and the TZ-string footer only when the header's version byte is exactly `"2"` (two sites). RFC 9636 (which obsoletes RFC 8536) defines versions `'2'`, `'3'` and `'4'`, each conforming to the one before (section 3.1), and says of readers in section 4: *"When reading a version 2 or higher file, readers SHOULD ignore the version 1 header and data block except for the purpose of skipping over them."* `zic` writes version 3 whenever a zone's footer needs the TZ-string extension of section 3.3.2 (a transition hour outside 0..24), and version 4 for leap-second tables with a truncation or expiry. In tzdata 2026c, 12 of 598 zones are version 3: Israel, Asia/Jerusalem, Asia/Tel_Aviv (`M3.4.4/26`), Asia/Gaza, Asia/Hebron (`/50`), America/Santiago, Chile/Continental, Chile/EasterIsland, Pacific/Easter, America/Nuuk, America/Godthab, America/Scoresbysund (`M3.5.0/-1`). For those files Tcl parses the 32-bit block. With `zic`'s default `-b slim` output that block is empty, so the zone loads as a single entry, LMT forever; with `-b fat` data the 32-bit transitions are read and the footer is lost, so the bug shows after 2037. Anything reading the system zoneinfo (`--with-tzdata=no`, or a zone not in Tcl's own tzdata) is affected. % clock format 0 -timezone :UTC ;# load the ensemble % ::tcl::clock::LoadZoneinfoFile Asia/Jerusalem % llength $::tcl::clock::TZData(:Asia/Jerusalem) 1 % ::tcl::clock::LoadZoneinfoFile Asia/Kolkata ;# a version-2 file % llength $::tcl::clock::TZData(:Asia/Kolkata) 8 **Reproduction without tzdata:** the attached `tcl-tz-repro.tcl` writes synthetic TZif files into a scratch zoneinfo directory in the shape of `clock-56.1`/`clock-56.2` (a version-2 control, version 3 with footer `<-02>2<-01>,M3.5.0/-1,M10.5.0/0`, version 3 with `IST-2IDT,M3.4.4/26,M10.5.0`, a version-4 header), prepends it to `::tcl::clock::ZoneinfoPaths`, and formats 2030-01-11 and 2030-07-11 12:00 UTC through each. Stock 8.6.18 and 9.0.4 return standard time for summer in all three non-control zones (`-02` for `-01`, `IST` for `IDT`). The script also covers two other clock bugs (separate tickets); the reader checks are the first block. **Fix** (attached `clock-tzif-versions-2-and-up.patch`, 8 lines against core-8-6-branch; applies to main at other offsets): 1. Both version checks read the 64-bit block and the footer for any version from 2 up - `[string is digit -strict $version] && $version >= 2` — the RFC's "2 or higher", and what glibc does (any nonzero version byte). 2. `ParsePosixTimeZone`'s two transition-time hour fields (groups 16 and 24) become `/ ( [-+]?[[:digit:]]{1,3} )` for section 3.3.2's range of -167..167. `ProcessPosixTimeZone` already scans the field with `%d` and adds seconds, so a negative hour needs no other change; hour 26 already fit the old pattern. **Verification:** the script's reader checks pass. On real data, all 12 version-3 zones and 10 version-2 controls were compared with glibc's `date` on the same installed files at 6,256 instants (30-day steps 2026–2045, hourly across the Greenland and Israel 2026 and 2031 transition weekends): 0 mismatches. `tests/clock.test` is unchanged by the fix. **Proposed tests:** `clock-56.4` (version 3, negative transition hour), `clock-56.5` (version 3, hour 26), `clock-56.6` (version 4 header). The script's `tzif` procedure builds each file in a dozen lines. - foundin changed to: "8.6.18, 9.0.4"
- is_private changed to: "0"
- login: "kenneth.kienle"
- priority changed to: "5 Medium"
- private_contact changed to: "39c7f150e83208e701f26c9bf329dc8b2f4bc4d1"
- resolution changed to: "None"
- severity changed to: "Minor"
- status changed to: "Open"
- submitter changed to: "kenneth.kienle"
- subsystem changed to: "06. Time Measurement"
- title changed to:
Clock reads TZif version 3 and 4 zoneinfo files as version 1 - zones with an extended footer lose all their transitions
- type changed to: "Bug"