From patchwork Tue Dec 2 23:46:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Perkins X-Patchwork-Id: 417180 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 012F3140180 for ; Wed, 3 Dec 2014 10:47:37 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id; q=dns; s= default; b=VgDlekWzNEJEHyKAJJZTTjeFIZsWhUjbf7th2atQ1/z/r3uCbEEm2 R6yzo+2aNR9wDR89LKKJ1FbFxy68uaXgVhOhBISNMKb5cIYlmXvSReOqCEJKphQh HA5rBxZ17kzS0X29eX+9Kp+beP4kFTvBoyivPTJdTiMG51DR1IzwuA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id; s=default; bh=YDFryuRoLxh+gW5qLRC8qtsxGSM=; b=g3CEOuXGZyJT9SbGMl4TcXXlz0tF Cijfn1+wE6doAIZrEetFAG+EmfXK6vTcSHm4M82HIB/gpG2JbieUAPr8iGSCvNWV 8rVH1KB7hXKYRicRfFu3S7qCaLYh40MhAHXB37hTs0IQIu6HeOneTn9/MCittMmR lz9YQuILApXr58s= Received: (qmail 15074 invoked by alias); 2 Dec 2014 23:47:32 -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 15063 invoked by uid 89); 2 Dec 2014 23:47:32 -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-ie0-f182.google.com X-Received: by 10.107.16.88 with SMTP id y85mr2112940ioi.56.1417564047802; Tue, 02 Dec 2014 15:47:27 -0800 (PST) From: James Perkins To: libc-alpha@sourceware.org Subject: [PATCH 1/2] [BZ #16141] strptime: extend %z range to UTC+14:00 Date: Tue, 2 Dec 2014 15:46:56 -0800 Message-Id: <1417564016-3572-1-git-send-email-james@loowit.net> This is a fix for [BZ #16141] strptime %z offset restriction. strptime supports the parsing of a timezone offset from UTC time into the broken-out time field tm_gmtoff. It supports timezone offsets between UTC-12:00 and UTC+12:00, returning an error (NULL) for values outside that range. However, there are valid international timezones outside the supported range. Extending the valid positive timezone offset to +14:00 allows for the correct parsing of several timezone offsets including: * Pacific/Auckland summer time (+13:00) * Pacific/Kiritimati (+14:00) * Pacific/Apia summer time (+14:00) James 2014-12-02 James Perkins james@loowit.net [BZ #16141] * time/strptime_l.c (__strptime_internal): Extend %z timezone offset range to UTC+14:00 to parse offsets typical of extreme Western Pacific timezones, like NZ and Samoa summer time and Christmas Island. --- time/strptime_l.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/time/strptime_l.c b/time/strptime_l.c index b3a612e..2140c47 100644 --- a/time/strptime_l.c +++ b/time/strptime_l.c @@ -777,7 +777,11 @@ __strptime_internal (rp, fmt, tmp, statep LOCALE_PARAM) return NULL; val = (val / 100) * 100 + ((val % 100) * 50) / 30; } - if (val > 1200) + /* minimum UTC-12, used aboard ships */ + if (neg && val > 1200) + return NULL; + /* maximum UTC+14, Pacific/Kiritimati and Pacific/Apia summer time */ + if (!neg && val > 1400) return NULL; tm->tm_gmtoff = (val * 3600) / 100; if (neg)