Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/time welcome to tzcode-2022a



details:   https://anonhg.NetBSD.org/src/rev/390d6edb91ef
branches:  trunk
changeset: 364406:390d6edb91ef
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Mar 22 17:48:39 2022 +0000

description:
welcome to tzcode-2022a

  Changes to code

    Fix bug when mktime gets confused by truncated TZif files with
    unspecified local time.  (Problem reported by Almaz Mingaleev.)

    Fix bug when 32-bit time_t code reads malformed 64-bit TZif data.
    (Problem reported by Christos Zoulas.)

    When reading a version 2 or later TZif file, the TZif reader now
    validates the version 1 header and data block only enough to skip
    over them, as recommended by RFC 8536 section 4.  Also, the TZif
    reader no longer mistakenly attempts to parse a version 1 TZIf
    file header as a TZ string.

    zdump -v now outputs "(localtime failed)" and "(gmtime failed)"
    when local time and UT cannot be determined for a timestamp.

diffstat:

 lib/libc/time/CONTRIBUTING |   68 +++++++++++++++-------------
 lib/libc/time/Makefile     |   13 +++--
 lib/libc/time/NEWS         |   60 +++++++++++++++++++++++++
 lib/libc/time/localtime.c  |  107 +++++++++++++++++++++++++++++---------------
 lib/libc/time/private.h    |    8 ++-
 lib/libc/time/theory.html  |   27 ++++++++--
 lib/libc/time/tz-link.html |   35 +++++---------
 lib/libc/time/tzselect.8   |    4 +-
 lib/libc/time/tzselect.ksh |   23 +++-----
 lib/libc/time/version      |    2 +-
 lib/libc/time/zdump.c      |   52 +++++++++++++++++----
 lib/libc/time/zic.c        |   17 ++++--
 12 files changed, 281 insertions(+), 135 deletions(-)

diffs (truncated from 875 to 300 lines):

diff -r 8c5e2b1b1b1a -r 390d6edb91ef lib/libc/time/CONTRIBUTING
--- a/lib/libc/time/CONTRIBUTING        Mon Mar 21 22:20:32 2022 +0000
+++ b/lib/libc/time/CONTRIBUTING        Tue Mar 22 17:48:39 2022 +0000
@@ -1,53 +1,58 @@
-Contributing to the tz code and data
+# Contributing to the tz code and data
+
+Please do not create issues or pull requests on GitHub, as the
+proper procedure for proposing and distributing patches is via
+email as described below.
 
 The time zone database is by no means authoritative: governments
 change timekeeping rules erratically and sometimes with little
 warning, the data entries do not cover all of civil time before
 1970, and undoubtedly errors remain in the code and data.  Feel
 free to fill gaps or fix mistakes, and please email improvements
-to tz%iana.org@localhost for use in the future.  In your email, please give
+to <tz%iana.org@localhost> for use in the future.  In your email, please give
 reliable sources that reviewers can check.
 
------
-
-Developers can contribute technical changes to the source code and
-data as follows.
+## Contributing technical changes
 
 To email small changes, please run a POSIX shell command like
 'diff -u old/europe new/europe >myfix.patch', and attach
-myfix.patch to the email.
+'myfix.patch' to the email.
 
 For more-elaborate or possibly-controversial changes,
 such as renaming, adding or removing zones, please read
-<https://www.iana.org/time-zones/repository/theory.html> or the file
-theory.html.  It is also good to browse the mailing list archives
+"Theory and pragmatics of the tz code and data"
+<https://www.iana.org/time-zones/repository/theory.html>.
+It is also good to browse the mailing list archives
 <https://mm.icann.org/pipermail/tz/> for examples of patches that tend
 to work well.  Additions to data should contain commentary citing
-reliable sources as justification.  Citations should use https: URLs
+reliable sources as justification.  Citations should use "https:" URLs
 if available.
 
 For changes that fix sensitive security-related bugs, please see the
-file SECURITY.
+distribution's 'SECURITY' file.
 
-Please submit changes against either the latest release in
+Please submit changes against either the latest release
 <https://www.iana.org/time-zones> or the main branch of the development
-repository.  The latter is preferred.  If you use Git the following
-workflow may be helpful:
+repository.  The latter is preferred.
+
+## Sample Git workflow for developing contributions
+
+If you use Git the following workflow may be helpful:
 
   * Copy the development repository.
 
-      git clone https://github.com/eggert/tz.git
-      cd tz
+        git clone https://github.com/eggert/tz.git
+        cd tz
 
   * Get current with the main branch.
 
-      git checkout main
-      git pull
+        git checkout main
+        git pull
 
   * Switch to a new branch for the changes.  Choose a different
     branch name for each change set.
 
-      git checkout -b mybranch
+        git checkout -b mybranch
 
   * Sleuth by using 'git blame'.  For example, when fixing data for
     Africa/Sao_Tome, if the command 'git blame africa' outputs a line
@@ -60,32 +65,33 @@
 
   * Debug the changes, e.g.:
 
-      make check
-      make install
-      ./zdump -v America/Los_Angeles
+        make check
+        make install
+        ./zdump -v America/Los_Angeles
 
   * For each separable change, commit it in the new branch, e.g.:
 
-      git add northamerica
-      git commit
+        git add northamerica
+        git commit
 
     See recent 'git log' output for the commit-message style.
 
-  * Create patch files 0001-*, 0002-*, ...
+  * Create patch files 0001-..., 0002-..., ...
 
-      git format-patch main
+        git format-patch main
 
-  * After reviewing the patch files, send the patches to tz%iana.org@localhost
+  * After reviewing the patch files, send the patches to <tz%iana.org@localhost>
     for others to review.
 
-      git send-email main
+        git send-email main
 
     For an archived example of such an email, see
+    "[PROPOSED] Fix off-by-1 error for Jamaica and T&C before 1913"
     <https://mm.icann.org/pipermail/tz/2018-February/026122.html>.
 
   * Start anew by getting current with the main branch again
     (the second step above).
 
-Please do not create issues or pull requests on GitHub, as the
-proper procedure for proposing and distributing patches is via
-email as illustrated above.
+-----
+
+This file is in the public domain.
diff -r 8c5e2b1b1b1a -r 390d6edb91ef lib/libc/time/Makefile
--- a/lib/libc/time/Makefile    Mon Mar 21 22:20:32 2022 +0000
+++ b/lib/libc/time/Makefile    Tue Mar 22 17:48:39 2022 +0000
@@ -399,9 +399,10 @@
 ZIC_INSTALL=   $(ZIC) -d '$(DESTDIR)$(TZDIR)' $(LEAPSECONDS)
 
 # The name of a Posix-compliant 'awk' on your system.
-# Older 'mawk' versions, such as the 'mawk' in Ubuntu 16.04, might dump core;
-# on Ubuntu you can work around this with
-#      AWK=            gawk
+# mawk 1.3.3 and Solaris 10 /usr/bin/awk do not work.
+# Also, it is better (though not essential) if 'awk' supports UTF-8,
+# and unfortunately mawk and busybox awk do not support UTF-8.
+# Try AWK=gawk or AWK=nawk if your awk has the abovementioned problems.
 AWK=           awk
 
 # The full path name of a Posix-compliant shell, preferably one that supports
@@ -466,7 +467,9 @@
 
 # Flags to give 'tar' when making a distribution.
 # Try to use flags appropriate for GNU tar.
-GNUTARFLAGS= --numeric-owner --owner=0 --group=0 --mode=go+u,go-w --sort=name
+GNUTARFLAGS= --format=pax --pax-option='delete=atime,delete=ctime' \
+  --numeric-owner --owner=0 --group=0 \
+  --mode=go+u,go-w --sort=name
 TARFLAGS=      `if tar $(GNUTARFLAGS) --version >/dev/null 2>&1; \
                 then echo $(GNUTARFLAGS); \
                 else :; \
@@ -742,7 +745,7 @@
 tzselect:      tzselect.ksh version
                VERSION=`cat version` && sed \
                        -e 's|#!/bin/bash|#!$(KSHELL)|g' \
-                       -e 's|AWK=[^}]*|AWK=$(AWK)|g' \
+                       -e 's|AWK=[^}]*|AWK='\''$(AWK)'\''|g' \
                        -e 's|\(PKGVERSION\)=.*|\1='\''($(PACKAGE)) '\''|' \
                        -e 's|\(REPORT_BUGS_TO\)=.*|\1=$(BUGEMAIL)|' \
                        -e 's|TZDIR=[^}]*|TZDIR=$(TZDIR)|' \
diff -r 8c5e2b1b1b1a -r 390d6edb91ef lib/libc/time/NEWS
--- a/lib/libc/time/NEWS        Mon Mar 21 22:20:32 2022 +0000
+++ b/lib/libc/time/NEWS        Tue Mar 22 17:48:39 2022 +0000
@@ -1,5 +1,65 @@
 News for the tz database
 
+Release 2022a - 2022-03-15 23:02:01 -0700
+
+  Briefly:
+    Palestine will spring forward on 2022-03-27, not -03-26.
+    zdump -v now outputs better failure indications.
+    Bug fixes for code that reads corrupted TZif data.
+
+  Changes to future timestamps
+
+    Palestine will spring forward on 2022-03-27, not 2022-03-26.
+    (Thanks to Heba Hamad.)  Predict future transitions for first
+    Sunday >= March 25.  Additionally, predict fallbacks to be the first
+    Friday on or after October 23, not October's last Friday, to be more
+    consistent with recent practice.  The first differing fallback
+    prediction is on 2025-10-24, not 2025-10-31.
+
+  Changes to past timestamps
+
+    From 1992 through spring 1996, Ukraine's DST transitions were at
+    02:00 standard time, not at 01:00 UTC.  (Thanks to Alois Treindl.)
+
+    Chile's Santiago Mean Time and its LMT precursor have been adjusted
+    eastward by 1 second to align with past and present law.
+
+  Changes to commentary
+
+    Add several references for Chile's 1946/1947 transitions, some of
+    which only affected portions of the country.
+
+  Changes to code
+
+    Fix bug when mktime gets confused by truncated TZif files with
+    unspecified local time.  (Problem reported by Almaz Mingaleev.)
+
+    Fix bug when 32-bit time_t code reads malformed 64-bit TZif data.
+    (Problem reported by Christos Zoulas.)
+
+    When reading a version 2 or later TZif file, the TZif reader now
+    validates the version 1 header and data block only enough to skip
+    over them, as recommended by RFC 8536 section 4.  Also, the TZif
+    reader no longer mistakenly attempts to parse a version 1 TZIf
+    file header as a TZ string.
+
+    zdump -v now outputs "(localtime failed)" and "(gmtime failed)"
+    when local time and UT cannot be determined for a timestamp.
+
+  Changes to build procedure
+
+    Distribution tarballs now use standard POSIX.1-1988 ustar format
+    instead of GNU format.  Although the formats are almost identical
+    for these tarballs, ustar headers' magic fields contain "ustar"
+    instead of "ustar ", and their version fields contain "00" instead
+    of " ".  The two formats are planned to diverge more significantly
+    for tzdb releases after 2242-03-16 12:56:31 UTC, when the ustar
+    format becomes obsolete and the tarballs switch to pax format, an
+    extension of ustar.  For details about these formats, please see
+    "pax - portable archive interchange", IEEE Std 1003.1-2017,
+    <https://pubs.opengroup.org/onlinepubs/9699919799/utilities/pax.html#tag_20_92_13>.
+
+
 Release 2021e - 2021-10-21 18:41:00 -0700
 
   Changes to future timestamps
diff -r 8c5e2b1b1b1a -r 390d6edb91ef lib/libc/time/localtime.c
--- a/lib/libc/time/localtime.c Mon Mar 21 22:20:32 2022 +0000
+++ b/lib/libc/time/localtime.c Tue Mar 22 17:48:39 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: localtime.c,v 1.126 2021/12/05 18:06:24 christos Exp $ */
+/*     $NetBSD: localtime.c,v 1.127 2022/03/22 17:48:39 christos Exp $ */
 
 /* Convert timestamp from time_t to struct tm.  */
 
@@ -12,7 +12,7 @@
 #if 0
 static char    elsieid[] = "@(#)localtime.c    8.17";
 #else
-__RCSID("$NetBSD: localtime.c,v 1.126 2021/12/05 18:06:24 christos Exp $");
+__RCSID("$NetBSD: localtime.c,v 1.127 2022/03/22 17:48:39 christos Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -115,6 +115,15 @@
 #define SMALLEST(a, b) (((a) < (b)) ? (a) : (b))
 #define BIGGEST(a, b)  (((a) > (b)) ? (a) : (b))
 
+/* This abbreviation means local time is unspecified.  */
+static char const UNSPEC[] = "-00";
+
+/* How many extra bytes are needed at the end of struct state's chars array.
+   This needs to be at least 1 for null termination in case the input
+   data isn't properly terminated, and it also needs to be big enough
+   for ttunspecified to work without crashing.  */
+enum { CHARS_EXTRA = BIGGEST(sizeof UNSPEC, 2) - 1 };
+
 #ifdef TZNAME_MAX
 #define MY_TZNAME_MAX  TZNAME_MAX
 #endif /* defined TZNAME_MAX */
@@ -133,8 +142,9 @@
        __time_t        ats[TZ_MAX_TIMES];
        unsigned char   types[TZ_MAX_TIMES];
        struct ttinfo   ttis[TZ_MAX_TYPES];
-       char            chars[/*CONSTCOND*/BIGGEST(BIGGEST(TZ_MAX_CHARS + 1,
-                               sizeof gmt), (2 * (MY_TZNAME_MAX + 1)))];
+       char            chars[/*CONSTCOND*/
+                           BIGGEST(BIGGEST(TZ_MAX_CHARS + CHARS_EXTRA,
+                           sizeof gmt), (2 * (MY_TZNAME_MAX + 1)))];
        struct lsinfo   lsis[TZ_MAX_LEAPS];
 
        /* The time type to use for early times or if no transitions.
@@ -235,6 +245,15 @@
        s->tt_ttisut = false;
 }
 
+/* Return true if SP's time type I does not specify local time.  */
+static bool
+ttunspecified(struct state const *sp, int i)
+{
+  char const *abbr = &sp->chars[sp->ttis[i].tt_desigidx];
+  /* memcmp is likely faster than strcmp, and is safe due to CHARS_EXTRA.  */
+  return memcmp(abbr, UNSPEC, sizeof UNSPEC) == 0;
+}
+
 static int_fast32_t
 detzcode(const char *const codep)
 {
@@ -491,35 +510,45 @@
        if (close(fid) < 0)
                return errno;
        for (stored = 4; stored <= 8; stored *= 2) {
-               int_fast32_t ttisstdcnt = detzcode(up->tzhead.tzh_ttisstdcnt);



Home | Main Index | Thread Index | Old Index