git: a5f14e4f9069 - main - tzcode: Use -00 only for invalid time zones
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 23 Sep 2025 12:59:09 UTC
The branch main has been updated by des:
URL: https://cgit.FreeBSD.org/src/commit/?id=a5f14e4f9069a8ffed66d923bb0ecf20d8a0e6af
commit a5f14e4f9069a8ffed66d923bb0ecf20d8a0e6af
Author: Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2025-09-23 12:56:11 +0000
Commit: Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2025-09-23 12:56:11 +0000
tzcode: Use -00 only for invalid time zones
As of tzcode 2025a, if we are unable to load a time zone, we set tzname
to "-00" to indicate an error. This penalizes users who simply don't
set TZ or create /etc/localtime as a faster way of setting the time zone
to UTC (pointing /etc/localtime at /usr/share/zoneinfo/UTC forces us to
parse it every time for no real benefit). To rectify this, use "-00"
only if TZ was set or zoneinit() returned something else than ENOENT.
MFC after: 3 days
Fixes: 967a49a21a27 ("Update tzcode to 2025b")
Reviewed by: philip
Differential Revision: https://reviews.freebsd.org/D52680
---
contrib/tzcode/localtime.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/contrib/tzcode/localtime.c b/contrib/tzcode/localtime.c
index 15afeeecb6d0..7ba72d730648 100644
--- a/contrib/tzcode/localtime.c
+++ b/contrib/tzcode/localtime.c
@@ -1649,9 +1649,13 @@ tzset_unlocked_name(char const *name)
lclptr = sp = malloc(sizeof *lclptr);
# endif
if (sp) {
- if (zoneinit(sp, name, TZLOAD_FROMENV | TZLOAD_TZSTRING) != 0) {
+ int err = zoneinit(sp, name, TZLOAD_FROMENV | TZLOAD_TZSTRING);
+ if (err != 0) {
zoneinit(sp, "", 0);
- strcpy(sp->chars, UNSPEC);
+ /* Abbreviate with "-00" if there was an error.
+ Do not treat a missing TZDEFAULT file as an error. */
+ if (name || err != ENOENT)
+ strcpy(sp->chars, UNSPEC);
}
if (0 < lcl)
strcpy(lcl_TZname, name);