From patchwork Wed Dec 3 22:46:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Perkins X-Patchwork-Id: 4064 X-Patchwork-Delegate: vapier@gentoo.org Received: (qmail 11968 invoked by alias); 3 Dec 2014 22:46:47 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 11862 invoked by uid 89); 3 Dec 2014 22:46:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ig0-f178.google.com X-Received: by 10.42.128.81 with SMTP id l17mr9158657ics.8.1417646801862; Wed, 03 Dec 2014 14:46:41 -0800 (PST) From: James Perkins To: libc-alpha@sourceware.org Subject: [PATCH v3 4/4] [BZ #16141] strptime: extend %z range to +/-9959 Date: Wed, 3 Dec 2014 14:46:00 -0800 Message-Id: <1417646760-19563-4-git-send-email-james@loowit.net> In-Reply-To: <1417646760-19563-1-git-send-email-james@loowit.net> References: <1417646760-19563-1-git-send-email-james@loowit.net> This is part of a fix for [BZ #16141] strptime %z offset restriction. Remove limits on the strptime %z timezone range, allowing strptime to parse time zone offsets from -9959 through +9959. strptime supports a %z input field descriptor, which parses a time zone offset from UTC time into the broken-out time field tm_gmtoff. The current implementation limits the range of valid offsets to the range -1200 to +1200, or if only the hour digits are present, -12 to +12. NULL is returned for offsets outside that range. However, the limits are too small for the following use cases: * Present day exceeds the +1200 limit: - Pacific/Auckland (New Zealand) summer time is +1300. - Pacific/Kiritimati (Christmas Island) is +1400. - Pacific/Apia (Samoa) summer time is +1400. * Historical offsets exceeded +1500/-1500. * POSIX supports -2459 to +2559. * Offsets up to +/-9959 may occasionally be useful. * Paul Eggert's notes provide additional detail: - https://sourceware.org/ml/libc-alpha/2014-12/msg00068.html - https://sourceware.org/ml/libc-alpha/2014-12/msg00072.html When 'make check' is run on glibc, tst-strptime2 will report the error with the output: round 13: strptime unexpectedly failed round 14: strptime unexpectedly failed round 15: strptime unexpectedly failed round 16: strptime unexpectedly failed round 17: strptime unexpectedly failed round 18: strptime unexpectedly failed round 19: strptime unexpectedly failed round 20: strptime unexpectedly failed round 21: strptime unexpectedly failed round 22: strptime unexpectedly failed round 23: strptime unexpectedly failed round 24: strptime unexpectedly failed round 25: strptime unexpectedly failed round 26: strptime unexpectedly failed The fix removes the +/-1200 range limit, permitting strptime to parse offsets from -9959 through +9959. The tst-strptime2 test will then succeed. James 2014-12-03 James Perkins james@loowit.net [BZ #16141] * time/strptime_l.c (__strptime_internal): Extend %z time zone offset range limits to UTC-99:59 through UTC+99:59 to parse current and historical use cases. --- time/strptime_l.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/time/strptime_l.c b/time/strptime_l.c index be35f3b..719f757 100644 --- a/time/strptime_l.c +++ b/time/strptime_l.c @@ -773,8 +773,6 @@ __strptime_internal (rp, fmt, tmp, statep LOCALE_PARAM) else if (val % 100 >= 60) /* Minutes valid range is 0 through 59. */ return NULL; - if (val > 1200) - return NULL; tm->tm_gmtoff = (val / 100) * 3600 + (val % 100) * 60; if (neg) tm->tm_gmtoff = -tm->tm_gmtoff;