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

Bug#71060: [PATCH] missing /etc/localtime causes timezone to be set to /etc/localtime



Package: libc6
Version: 2.1.3-10

If TZ is not set, glibc uses "/etc/localtime" as the timezone.
Unfortunately, if /etc/localtime doesn't exist, it ends up using the
string "/etc/localtime" as the timezone.  This sucks.  There appears to
be some dead code which once checked for this case but now, due to some
invariants, does nothing.  The appended patch allows this code to do its
work.  That is, when TZ is unset or is set to the empty string, the
timezone will default to UTC.

Matt

--- tzset.c.orig	Wed Sep  6 21:55:35 2000
+++ tzset.c	Wed Sep  6 21:56:46 2000
@@ -130,6 +130,7 @@
      int always;
 {
   static int is_initialized;
+  const char *env_tz;
   register const char *tz;
   register size_t l;
   char *tzbuf;
@@ -141,7 +142,7 @@
   is_initialized = 1;
 
   /* Examine the TZ environment variable.  */
-  tz = getenv ("TZ");
+  tz = env_tz = getenv ("TZ");
   if (tz == NULL)
     /* No user specification; use the site-wide default.  */
     tz = TZDEFAULT;
@@ -175,7 +176,7 @@
 
   /* No data file found.  Default to UTC if nothing specified.  */
 
-  if (tz == NULL || *tz == '\0')
+  if (env_tz == NULL || *env_tz == '\0')
     {
       tz_rules[0].name = tz_rules[1].name = "UTC";
       tz_rules[0].type = tz_rules[1].type = J0;



Reply to: