On 2026-11-02 02:09, Dmitry Khalanskiy via tz wrote:
- if (!lastat || lastat->at < rpytime(&xr, max_year - 1)) {
+ if (0 == timecnt || lastat->at < rpytime(&xr, max_year - 1)) {
addtt(rpytime(&xr, max_year + 1),
lastat ? lastat->type : defaulttype);
Thanks for reporting the problem. However, I see some problems with the patch.
1. From what I can see the data are "uninitialized" only in an
application-oriented way (a reused array) and this does not result in undefined behavior
as far as the C standard is concerned.
2. Changing that "!lastat" to the equivalent of "!timecnt" means that two lines down we must also
change the first "lastat" to "timecnt".
3. The patch changes the handling of Etc/UTC0 as part of tzdata.zi to be like
the handling of Etc/UTC0 by itself. But that's backwards, as the latter is
wrong (it generates duplicate transition timestamps in the TZif output,
contrary to the TZif RFC) whereas the former is correct.
I installed the attached patch to try to fix all this; please give it a try,
and further comments are welcome. Thanks again for reporting the bug.
From e28a7a4a1a5f497baae27ee63603efa88537607a Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email protected]>
Date: Mon, 2 Nov 2026 23:23:27 -0800
Subject: [PROPOSED] =?UTF-8?q?Fix=20=E2=80=98zic=20-r/@12717475200?=
=?UTF-8?q?=E2=80=99?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
zic -r/@HI no longer outputs duplicate transition timestamps when
HI is the UTC start of the 403rd year after the last ordinary
transition. For example, ‘-r/@12717475200’ would sometimes output
duplicate transitions at 2373-01-01 00:00:00 UTC if the last
ordinary transition was in 1970. This fixes a failure to conform
to Internet RFC 9636 §3.2.
* NEWS: Document the fix.
* zic.c (limitrange): Cutoff at HI, not at HI + 1.
(outzone): Test timecnt, not lastat, when deciding whether there
are transition times in the current Zone. This fixes a problem
when there are multiple Zones, timecnt is zero, and lastat is left
over from the previous zone. (Problem reported by Dmitry
Khalanskiy.)
---
NEWS | 10 ++++++++++
zic.c | 10 +++++-----
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/NEWS b/NEWS
index 7a05dc32..267530e2 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,15 @@
News for the tz database
+Unreleased, experimental changes
+
+ Changes to code
+
+ zic -r/@HI no longer outputs duplicate transition timestamps when
+ HI is the UTC start of the 403rd year after the last ordinary
+ transition. (Problem reported by Dmitry Khalanskiy.) This fixes
+ a failure to conform to Internet RFC 9636 §3.2.
+
+
Release 2026f - 2026-10-27 23:16:49 -0700
Briefly:
diff --git a/zic.c b/zic.c
index cd0dcac2..46954fc9 100644
--- a/zic.c
+++ b/zic.c
@@ -2630,11 +2630,11 @@ limitrange(struct timerange r, zic_t lo, zic_t hi,
}
- /* Omit ordinary and leap second transitions greater than HI + 1. */
+ /* Omit ordinary and leap second transitions greater than HI. */
if (hi < max_time) {
- while (0 < r.count && hi + 1 < ats[r.base + r.count - 1])
+ while (0 < r.count && hi < ats[r.base + r.count - 1])
r.count--;
- while (0 < r.leapcount && hi + 1 < leap[r.leapbase + r.leapcount - 1].trans)
+ while (0 < r.leapcount && hi < leap[r.leapbase + r.leapcount - 1].trans)
r.leapcount--;
}
@@ -3733,9 +3733,9 @@ outzone(const struct zone *zpfirst, ptrdiff_t zonecount)
for (lastat = attypes, i = 1; i < timecnt; i++)
if (attypes[i].at > lastat->at)
lastat = &attypes[i];
- if (!lastat || lastat->at < rpytime(&xr, max_year - 1)) {
+ if (!timecnt || lastat->at < rpytime(&xr, max_year - 1)) {
addtt(rpytime(&xr, max_year + 1),
- lastat ? lastat->type : defaulttype);
+ timecnt ? lastat->type : defaulttype);
attypes[timecnt - 1].dontmerge = true;
}
}
--
2.56.0