From 85342832bae78a9371f0f9a134e4b85faf4d6a9a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= <des@FreeBSD.org>
Date: Mon, 22 Sep 2025 17:59:00 +0200
Subject: [PATCH 1/1] Use -00 only for invalid time zones.

If TZ is unset and TZDEFAULT does not exist, fall back to "UTC" as
before, reserving "-00" for when either TZ or the content of TZDEFAULT
is invalid.
---
 localtime.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/localtime.c b/localtime.c
index f534383b..d1250b00 100644
--- a/localtime.c
+++ b/localtime.c
@@ -1484,9 +1484,11 @@ tzset_unlocked(void)
     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);
+      if (name != NULL || err != ENOENT)
+        strcpy(sp->chars, UNSPEC);
     }
     if (0 < lcl)
       strcpy(lcl_TZname, name);
-- 
2.51.0

