diff mbox series

time: Remove assert in reading of tz file

Message ID f958e61fd11944e2b179ab837f6b7e84@axis.com
State New
Headers show
Series time: Remove assert in reading of tz file | expand

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent
dj/TryBot-32bit success Build for i686

Commit Message

Christopher Wong Dec. 6, 2021, 2:50 p.m. UTC

Comments

Florian Weimer Dec. 6, 2021, 3:10 p.m. UTC | #1
* Christopher Wong via Libc-alpha:

> diff --git a/time/tzfile.c b/time/tzfile.c
> index 190a777152..874e10c9c7 100644
> --- a/time/tzfile.c
> +++ b/time/tzfile.c
> @@ -429,12 +429,7 @@ __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);
> -      __tzname[0] = __tzstring (zone_names);
> -    }
> +    __tzname[0] = __tzstring (zone_names);
>    if (__tzname[1] == NULL)
>      __tzname[1] = __tzname[0];

Is this patch required to avoid an assert with 2021d and later?

Would you be able to add a test case using a precomputed zone file?

Thanks,
Florian
Christopher Wong Dec. 6, 2021, 3:16 p.m. UTC | #2
This patch is needed if the tzfile is compiled using the truncated option -r in 2021d and later.


I know how to create the zone file, but I haven't run the test case before. Would probably take me some time to put that up.


Best Regards,

Christopher Wong
diff mbox series

Patch

From d1f0f7a09765ce7bb80d7d6bdd00e39bf7ca5d54 Mon Sep 17 00:00:00 2001
From: Christopher Wong <christopher.wong@axis.com>
Date: Mon, 6 Dec 2021 14:48:33 +0100
Subject: [PATCH] time: Remove assert in reading of tz file
To: libc-alpha@sourceware.org

The assumption of "__tzname[0] == NULL" then there must be no transition
and "num_types == 1" is obsolete. The case when the tz file is truncated
then "__tzname[0] == NULL" happens even when there is one transition.

The "num_types == 1" is kept up to version 2021c of the tzdb. Starting
from version 2021d of the tzdb the truncation introduces "-00" time zone
abbreviations for intervals with Universal Time (UT) offsets that are
unspecified. In other words, it means "num_types == 2".
---
 time/tzfile.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/time/tzfile.c b/time/tzfile.c
index 190a777152..874e10c9c7 100644
--- a/time/tzfile.c
+++ b/time/tzfile.c
@@ -429,12 +429,7 @@  __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);
-      __tzname[0] = __tzstring (zone_names);
-    }
+    __tzname[0] = __tzstring (zone_names);
   if (__tzname[1] == NULL)
     __tzname[1] = __tzname[0];
 
-- 
2.20.1