From patchwork Fri Dec 17 20:38:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans-Peter Nilsson X-Patchwork-Id: 49068 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C5D3F3858010 for ; Fri, 17 Dec 2021 20:39:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C5D3F3858010 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1639773564; bh=k77HSVJHkVQek7IDgTz3wqZ16zHbB/oEJnd5JJWBQS4=; h=To:In-Reply-To:Subject:References:Date:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=ehNn3kPnLgN858Q5iy3oj1FP1617H7SfZ9miuCq/+Ih4mU5gU0kmQDkC7iRDAF+JM aFlUh6kQeqjU9p0gjvXt+muMwDs9HRcFlgW8c5B3tim/Mf6EG303uuZdqgkt6Iw490 8rT9j4LUeJxHmU2g4PB/DD0RRW5rWKJDd69FNV+I= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from smtp2.axis.com (smtp2.axis.com [195.60.68.18]) by sourceware.org (Postfix) with ESMTPS id 84E383858410 for ; Fri, 17 Dec 2021 20:38:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 84E383858410 To: , Paul Eggert In-Reply-To: <949e52bb-05a6-5ae6-edd1-37382384a554@cs.ucla.edu> (message from Paul Eggert on Fri, 17 Dec 2021 03:51:50 +0100) Subject: [PATCH v3 1/2] timezone: handle truncated timezones from tzcode-2021d and later (BZ #28707) MIME-Version: 1.0 References: <20211217005744.E099F203C8@pchp3.se.axis.com> <949e52bb-05a6-5ae6-edd1-37382384a554@cs.ucla.edu> Message-ID: <20211217203800.61364203B0@pchp3.se.axis.com> Date: Fri, 17 Dec 2021 21:38:00 +0100 X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Hans-Peter Nilsson via Libc-alpha From: Hans-Peter Nilsson Reply-To: Hans-Peter Nilsson Cc: Christopher.Wong@axis.com Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" When using a timezone file with a truncated starting time, generated by the zic in IANA tzcode-2021d a.k.a. tzlib-2021d (also in tzlib-2021e; current as of this writing), glibc asserts in __tzfile_read (on e.g. tzset() for this file) and you may find lines matching "tzfile.c:435: __tzfile_read: Assertion `num_types == 1' failed" in your syslog. One example of such a file is the tzfile for Asuncion generated by tzlib-2021e as follows, using the tzlib-2021e zic: "zic -d DEST -r @1546300800 -L /dev/null -b slim SOURCE/southamerica". Note that in its type 2 header, it has two entries in its "time-types" array (types), but only one entry in its "transition types" array (type_idxs). This is valid and expected already in the published RFC8536, and not even frowned upon: "Local time for timestamps before the first transition is specified by the first time type (time type 0)" ... "every nonzero local time type index SHOULD appear at least once in the transition type array". Note the "nonzero ... index". Until the 2021d zic, index 0 has been shared by the first valid transition but with 2021d it's separate, set apart as a placeholder and only "implicitly" indexed. (A draft update of the RFC mandates that the entry at index 0 is a placeholder in this case, hence can no longer be shared.) * time/tzfile.c (__tzfile_read): Don't assert when no transitions are found. Co-authored-by: Christopher Wong --- time/tzfile.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/time/tzfile.c b/time/tzfile.c index 190a777152b3..8668392ad387 100644 --- a/time/tzfile.c +++ b/time/tzfile.c @@ -431,8 +431,8 @@ __tzfile_read (const char *file, size_t extra, char **extrap) if (__tzname[0] == NULL) { /* This should only happen if there are no transition rules. - In this case there should be only one single type. */ - assert (num_types == 1); + In this case there's usually only one single type, unless + e.g. the data file has a truncated time-range. */ __tzname[0] = __tzstring (zone_names); } if (__tzname[1] == NULL)