From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/13270 Path: news.gmane.org!.POSTED!not-for-mail From: Benjamin Peterson Newsgroups: gmane.linux.lib.musl.general Subject: [PATCH v2] always reset DST rules during tzset Date: Sat, 15 Sep 2018 10:05:24 -0700 Message-ID: <20180915170524.18964-2-benjamin@python.org> References: <20180915011634.GP1878@brightrain.aerifal.cx> <20180915170524.18964-1-benjamin@python.org> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1537031027 10795 195.159.176.226 (15 Sep 2018 17:03:47 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 15 Sep 2018 17:03:47 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-13286-gllmg-musl=m.gmane.org@lists.openwall.com Sat Sep 15 19:03:43 2018 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1g1Dyw-0002hr-JX for gllmg-musl@m.gmane.org; Sat, 15 Sep 2018 19:03:42 +0200 Original-Received: (qmail 17604 invoked by uid 550); 15 Sep 2018 17:05:50 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 17535 invoked from network); 15 Sep 2018 17:05:49 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=python.org; s=200901; t=1537031138; bh=kkMLuGb/SYWlFzo0f1KdQvP4aFnLMVJ2rfPiXVy5w0s=; h=From:To:Subject:Date:In-Reply-To:References:From; b=e5e/KV/bpPurCOf7J+1mHPgdah+S+bvm52YV/j4rUikVp1QSGI1SDKeWW7hiRLLrp NOLhmhD/V98lSkzaYo15MlM9GQ1k4iDff1Llz3eg3iKsfUxsKFtEoMZnPfFM+vkmJ+ 83TmyYAY2ltYNtvP+bO0go0CGiB098IaGXLv+MQw= X-ME-Proxy: X-ME-Sender: X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180915170524.18964-1-benjamin@python.org> Xref: news.gmane.org gmane.linux.lib.musl.general:13270 Archived-At: do_tzset() did't always reset the DST transition rules r0 and r1. That means the rules from older TZ settings could leak into newer ones. The following program demonstrates this bug. It should print out the same timezone twice but doesn't due to the leaky state. int main() { time_t t = 0; struct tm p; setenv("TZ", "STD-1DST", 1); localtime_r(&t, &p); printf("%s\n", p.tm_zone); setenv("TZ", "STD-1DST,M3.2.0,M11.1.0", 1); tzset(); setenv("TZ", "STD-1DST", 1); localtime_r(&t, &p); printf("%s\n", p.tm_zone); return 0; } --- src/time/__tz.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/time/__tz.c b/src/time/__tz.c index 51e66514..185642e8 100644 --- a/src/time/__tz.c +++ b/src/time/__tz.c @@ -130,6 +130,8 @@ static void do_tzset() if (old_tz && !strcmp(s, old_tz)) return; + for (i=0; i<5; i++) r0[i] = r1[i] = 0; + if (zi) __munmap((void *)zi, map_size); /* Cache the old value of TZ to check if it has changed. Avoid @@ -194,7 +196,6 @@ static void do_tzset() const unsigned char *p; __tzname[0] = __tzname[1] = 0; __daylight = __timezone = dst_off = 0; - for (i=0; i<5; i++) r0[i] = r1[i] = 0; for (p=types; p