From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/6277 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: Error in interpreting posix timezone TZ environment variable by musl-libc Date: Wed, 8 Oct 2014 17:11:02 -0400 Message-ID: <20141008211102.GT23797@brightrain.aerifal.cx> References: <20141008194429.GG17442@localhost> <20141008205918.GS23797@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="CblX+4bnyfN0pR09" X-Trace: ger.gmane.org 1412802693 24252 80.91.229.3 (8 Oct 2014 21:11:33 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 8 Oct 2014 21:11:33 +0000 (UTC) Cc: musl@lists.openwall.com To: vlse Original-X-From: musl-return-6290-gllmg-musl=m.gmane.org@lists.openwall.com Wed Oct 08 23:11:26 2014 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1XbyW1-00057z-Pg for gllmg-musl@plane.gmane.org; Wed, 08 Oct 2014 23:11:21 +0200 Original-Received: (qmail 13837 invoked by uid 550); 8 Oct 2014 21:11:20 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 13829 invoked from network); 8 Oct 2014 21:11:20 -0000 Content-Disposition: inline In-Reply-To: <20141008205918.GS23797@brightrain.aerifal.cx> User-Agent: Mutt/1.5.21 (2010-09-15) Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:6277 Archived-At: --CblX+4bnyfN0pR09 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Oct 08, 2014 at 04:59:18PM -0400, Rich Felker wrote: > On Thu, Oct 09, 2014 at 01:14:29AM +0530, vlse wrote: > > musl-libc stable 1.0.3 has wrong implementation of posix timezone TZ environmental variable. > > For e.g. if I set TZ="IST-5:30" and use busybox date command > > compiled with musl-libc it's show One hour early than actual. Same > > with c code using asctime from musl-libc. > > > > Any known fix. > > Can you show the expected and actual output of the date command, both > with TZ=IST-5:30 and TZ=GMT? Never mind -- I found the bug. I have a patch attached for current git master, and I think it will apply cleanly to 1.0.3 too, but I haven't checked yet. I'll be making a new release (1.1.5) from the mainline branch soon but an updated 1.0.x release might take longer since there's nontrivial backporting work to be done for other bugs too. If you have trouble applying the patch let me know. Rich --CblX+4bnyfN0pR09 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="tz_neg_off.diff" diff --git a/src/time/__tz.c b/src/time/__tz.c index 92c43a5..4ce2025 100644 --- a/src/time/__tz.c +++ b/src/time/__tz.c @@ -36,19 +36,16 @@ static int getint(const char **p) return x; } -static int getsigned(const char **p) +static int getoff(const char **p) { + int neg = 0; if (**p == '-') { ++*p; - return -getint(p); + neg = 1; + } else if (**p == '+') { + ++*p; } - if (**p == '+') ++*p; - return getint(p); -} - -static int getoff(const char **p) -{ - int off = 3600*getsigned(p); + int off = 3600*getint(p); if (**p == ':') { ++*p; off += 60*getint(p); @@ -57,7 +54,7 @@ static int getoff(const char **p) off += getint(p); } } - return off; + return neg ? -off : off; } static void getrule(const char **p, int rule[5]) --CblX+4bnyfN0pR09--