mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: vlse <vlse@veera.biz>
Cc: musl@lists.openwall.com
Subject: Re: Error in interpreting posix timezone TZ environment variable by musl-libc
Date: Wed, 8 Oct 2014 17:11:02 -0400	[thread overview]
Message-ID: <20141008211102.GT23797@brightrain.aerifal.cx> (raw)
In-Reply-To: <20141008205918.GS23797@brightrain.aerifal.cx>

[-- Attachment #1: Type: text/plain, Size: 926 bytes --]

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

[-- Attachment #2: tz_neg_off.diff --]
[-- Type: text/plain, Size: 764 bytes --]

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

  reply	other threads:[~2014-10-08 21:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-08 19:44 vlse
2014-10-08 20:59 ` Rich Felker
2014-10-08 21:11   ` Rich Felker [this message]
2014-10-09  3:23     ` vlse
2014-10-09  3:29       ` Rich Felker
2014-10-09  6:03         ` vlse

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=20141008211102.GT23797@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    --cc=vlse@veera.biz \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).