This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH]   tzset did not catch changes to localtime  [BZ #21060 ]


Hi, 
If users modified the local timezone file (usually /etc/localtime) while keep the TZ environment variable untouched, tzset will not recalculate tzname. This is not right. Patch attached should fix this problem, is it OK for trunk?


diff -Nuarp a/time/tzset.c b/time/tzset.c
--- a/time/tzset.c	2017-10-31 17:28:58.105026060 +0800
+++ b/time/tzset.c	2017-10-31 17:28:43.470025216 +0800
@@ -387,21 +387,18 @@ tzset_internal (int always)
   if (tz && *tz == ':')
     ++tz;

-  /* Check whether the value changed since the last run.  */
-  if (old_tz != NULL && tz != NULL && strcmp (tz, old_tz) == 0)
-    /* No change, simply return.  */
-    return;
-
   if (tz == NULL)
     /* No user specification; use the site-wide default.  */
     tz = TZDEFAULT;

-  tz_rules[0].name = NULL;
-  tz_rules[1].name = NULL;
-
-  /* Save the value of `tz'.  */
-  free (old_tz);
-  old_tz = tz ? __strdup (tz) : NULL;
+  /* Check whether the value changed since the last run.  */
+  if ((old_tz == NULL)
+      || (old_tz != NULL && strcmp (tz, old_tz) != 0))
+    {
+      /* Save the value of `tz'.  */
+      free (old_tz);
+      old_tz = tz ? __strdup (tz) : NULL;
+    }

   /* Try to read a data file.  */
   __tzfile_read (tz, 0, NULL);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]