From patchwork Fri May 18 12:11:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 27324 Received: (qmail 46112 invoked by alias); 18 May 2018 12:12:01 -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 46087 invoked by uid 89); 18 May 2018 12:12:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-23.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, KAM_SHORT, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=1900, HCc:D*fr, dates, H*r:sk:dhcp-19 X-HELO: mx1.redhat.com Subject: Re: [PATCH] Use 64-bit time_t for time zone file parsing To: Joseph Myers , Paul Eggert Cc: Andreas Schwab , GNU C Library , Albert ARIBAUD References: <264af3e6-84ae-d1a4-c204-c00786b61dd9@redhat.com> From: Florian Weimer Message-ID: <51268a51-c790-43fa-ca0d-d06773a68230@redhat.com> Date: Fri, 18 May 2018 14:11:55 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: On 05/17/2018 11:06 PM, Joseph Myers wrote: > Does this use of 64-bit time_t fix bug 19738 ("__tzfile_default 32-bit > time_t overflow")? If it does, we should add a testcase for that bug then > resolve it as FIXED in 2.28. Looks like it. Here's a test case which fails before on i386 (assuming that the system posixrules file as the required contents) and passes afterwards. I would call the bug fixed because dates where the overflow occurs with a 64-bit (internal) time_t are after the expected life-time of the sun, where daylight savings time is certainly meaningless. Thanks, Florian Subject: [PATCH] time: Add test case for bug 19738 To: libc-alpha@sourceware.org 2018-05-18 Florian Weimer [BZ #19738] * time/tst-posixrules-overflow.c (do_test): New file. * time/Makefile (tests): Add it. diff --git a/time/Makefile b/time/Makefile index 0db1206820..5454fe37e3 100644 --- a/time/Makefile +++ b/time/Makefile @@ -43,7 +43,7 @@ tests := test_time clocktest tst-posixtz tst-strptime tst_wcsftime \ tst-getdate tst-mktime tst-mktime2 tst-ftime_l tst-strftime \ tst-mktime3 tst-strptime2 bug-asctime bug-asctime_r bug-mktime1 \ tst-strptime3 bug-getdate1 tst-strptime-whitespace tst-ftime \ - tst-tzname + tst-tzname tst-posixrules-overflow include ../Rules diff --git a/time/tst-posixrules-overflow.c b/time/tst-posixrules-overflow.c new file mode 100644 index 0000000000..13d0789a93 --- /dev/null +++ b/time/tst-posixrules-overflow.c @@ -0,0 +1,43 @@ +/* Check processing of posixrules/TZDEFRULES (bug 19738). + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + +static int +do_test (void) +{ + TEST_COMPARE (setenv ("TZ", "STD+8DST", 1), 0); + tzset (); + time_t epoch = 1467414184; + struct tm *tm = localtime (&epoch); + TEST_VERIFY_EXIT (tm != NULL); + TEST_COMPARE (tm->tm_year, 2016 - 1900); + TEST_COMPARE (tm->tm_mon, 7 - 1); + TEST_COMPARE (tm->tm_mday, 1); + TEST_COMPARE (tm->tm_hour, 16); + TEST_COMPARE (tm->tm_min, 3); + TEST_COMPARE (tm->tm_sec, 4); + TEST_COMPARE (tm->tm_wday, 5); + TEST_COMPARE (tm->tm_yday, 183 - 1); + TEST_VERIFY (tm->tm_isdst); + return 0; +} + +#include