4df9e3
commit c36f64aa6dff13b12a1e03a185e75a50fa9f6a4c
4df9e3
Author: Hans-Peter Nilsson <hp@axis.com>
4df9e3
Date:   Fri Dec 17 21:38:00 2021 +0100
4df9e3
4df9e3
    timezone: handle truncated timezones from tzcode-2021d and later (BZ #28707)
4df9e3
    
4df9e3
    When using a timezone file with a truncated starting time,
4df9e3
    generated by the zic in IANA tzcode-2021d a.k.a. tzlib-2021d
4df9e3
    (also in tzlib-2021e; current as of this writing), glibc
4df9e3
    asserts in __tzfile_read (on e.g. tzset() for this file) and
4df9e3
    you may find lines matching "tzfile.c:435: __tzfile_read:
4df9e3
    Assertion `num_types == 1' failed" in your syslog.
4df9e3
    
4df9e3
    One example of such a file is the tzfile for Asuncion
4df9e3
    generated by tzlib-2021e as follows, using the tzlib-2021e zic:
4df9e3
    "zic -d DEST -r @1546300800 -L /dev/null -b slim
4df9e3
    SOURCE/southamerica".  Note that in its type 2 header, it has
4df9e3
    two entries in its "time-types" array (types), but only one
4df9e3
    entry in its "transition types" array (type_idxs).
4df9e3
    
4df9e3
    This is valid and expected already in the published RFC8536, and
4df9e3
    not even frowned upon: "Local time for timestamps before the
4df9e3
    first transition is specified by the first time type (time type
4df9e3
    0)" ... "every nonzero local time type index SHOULD appear at
4df9e3
    least once in the transition type array".  Note the "nonzero ...
4df9e3
    index".  Until the 2021d zic, index 0 has been shared by the
4df9e3
    first valid transition but with 2021d it's separate, set apart
4df9e3
    as a placeholder and only "implicitly" indexed.  (A draft update
4df9e3
    of the RFC mandates that the entry at index 0 is a placeholder
4df9e3
    in this case, hence can no longer be shared.)
4df9e3
    
4df9e3
            * time/tzfile.c (__tzfile_read): Don't assert when no transitions
4df9e3
            are found.
4df9e3
    
4df9e3
    Co-authored-by: Christopher Wong <Christopher.Wong@axis.com>
4df9e3
4df9e3
diff --git a/time/tzfile.c b/time/tzfile.c
4df9e3
index 190a777152..8668392ad3 100644
4df9e3
--- a/time/tzfile.c
4df9e3
+++ b/time/tzfile.c
4df9e3
@@ -431,8 +431,8 @@ __tzfile_read (const char *file, size_t extra, char **extrap)
4df9e3
   if (__tzname[0] == NULL)
4df9e3
     {
4df9e3
       /* This should only happen if there are no transition rules.
4df9e3
-	 In this case there should be only one single type.  */
4df9e3
-      assert (num_types == 1);
4df9e3
+	 In this case there's usually only one single type, unless
4df9e3
+	 e.g. the data file has a truncated time-range.  */
4df9e3
       __tzname[0] = __tzstring (zone_names);
4df9e3
     }
4df9e3
   if (__tzname[1] == NULL)