diff options
author | Rich Felker <dalias@aerifal.cx> | 2014-10-09 23:44:02 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2015-03-30 01:15:45 -0400 |
commit | 02ccece69864c006bafd9c318402195c9d48aa4d (patch) | |
tree | e6565b951ac39beff3d0f319eb93b3e00ebd5b95 /src/time | |
parent | 9882dc933dd7e3cc6bf645153778c7ef48032018 (diff) | |
download | musl-02ccece69864c006bafd9c318402195c9d48aa4d.tar.gz musl-02ccece69864c006bafd9c318402195c9d48aa4d.tar.bz2 musl-02ccece69864c006bafd9c318402195c9d48aa4d.tar.xz musl-02ccece69864c006bafd9c318402195c9d48aa4d.zip |
fix handling of negative offsets in timezone spec strings
previously, the hours were considered as a signed quantity while
minutes and seconds were always treated as positive offsets. however,
semantically the '-' sign should negate the whole hh:mm:ss offset.
this bug only affected timezones east of GMT with non-whole-hours
offsets, such as those used in India and Nepal.
(cherry picked from commit 08b996d180323775d5457944eefbb8a51ea72539)
Diffstat (limited to 'src/time')
-rw-r--r-- | src/time/__tz.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/time/__tz.c b/src/time/__tz.c index f56ef305..17d1adff 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]) |