Skip to content

Commit a5f14e4

Browse files
committed
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: 967a49a ("Update tzcode to 2025b") Reviewed by: philip Differential Revision: https://reviews.freebsd.org/D52680
1 parent 3aac05f commit a5f14e4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

contrib/tzcode/localtime.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,9 +1649,13 @@ tzset_unlocked_name(char const *name)
16491649
lclptr = sp = malloc(sizeof *lclptr);
16501650
# endif
16511651
if (sp) {
1652-
if (zoneinit(sp, name, TZLOAD_FROMENV | TZLOAD_TZSTRING) != 0) {
1652+
int err = zoneinit(sp, name, TZLOAD_FROMENV | TZLOAD_TZSTRING);
1653+
if (err != 0) {
16531654
zoneinit(sp, "", 0);
1654-
strcpy(sp->chars, UNSPEC);
1655+
/* Abbreviate with "-00" if there was an error.
1656+
Do not treat a missing TZDEFAULT file as an error. */
1657+
if (name || err != ENOENT)
1658+
strcpy(sp->chars, UNSPEC);
16551659
}
16561660
if (0 < lcl)
16571661
strcpy(lcl_TZname, name);

0 commit comments

Comments
 (0)