public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: <ma.jiang@zte.com.cn>
To: <libc-alpha@sourceware.org>
Subject: [PATCH]   tzset did not catch changes to localtime  [BZ #21060 ]
Date: Thu, 02 Nov 2017 09:03:00 -0000	[thread overview]
Message-ID: <201711021703324026436@zte.com.cn> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 1235 bytes --]

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);

             reply	other threads:[~2017-11-02  9:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-02  9:03 ma.jiang [this message]
2017-11-02 15:33 ` Carlos O'Donell
2017-11-07 10:27   ` ma.jiang
2017-11-02 23:48 ` J William Piggott
2017-11-03  8:16   ` 答复: " ma.jiang
2018-12-17  9:40 ma.jiang
2018-12-17  9:40 ` [PATCH] " Andreas Schwab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201711021703324026436@zte.com.cn \
    --to=ma.jiang@zte.com.cn \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).