Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20261126204717.661164-1-khem.raj@oss.qualcomm.com>
Date: Thu, 26 Nov 2026 12:47:17 -0800
From: Khem Raj <raj.khem@...il.com>
To: musl@...ts.openwall.com
Cc: Khem Raj <khem.raj@....qualcomm.com>
Subject: [PATCH] time: fix pre-transition lookup in single-transition TZif files

With exactly one TZif transition, scan_trans() treats index 0 as the
last transition before checking whether the timestamp precedes it.
This applies the footer rule too early. Check the pre-transition
case first so it reaches the existing fallback, without changing
how that fallback chooses a time type. so times before that transition
are handled by the POSIX TZ string in the footer instead of the
lowest-index non-DST type.

Check for t before the first transition first.
---
 src/time/__tz.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/time/__tz.c b/src/time/__tz.c
index df57fec1..0f57a1d9 100644
--- a/src/time/__tz.c
+++ b/src/time/__tz.c
@@ -288,9 +288,10 @@ static size_t scan_trans(long long t, int local, size_t *alt)
 	}
 
 	/* First and last entry are special. First means to use lowest-index
-	 * non-DST type. Last means to apply POSIX-style rule if available. */
+	 * non-DST type. Last means to apply POSIX-style rule if available.
+	 * Check for t before the first transition before checking for the
+	 * last entry, since with only one transition they are the same. */
 	n = (index-trans)>>scale;
-	if (a == n-1) return -1;
 	if (a == 0) {
 		x = zi_read32(trans);
 		if (scale == 3) x = x<<32 | zi_read32(trans + 4);
@@ -308,6 +309,7 @@ static size_t scan_trans(long long t, int local, size_t *alt)
 			return j/6;
 		}
 	}
+	if (a == n-1) return -1;
 
 	/* Try to find a neighboring opposite-DST-status rule. */
 	if (alt) {

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.