From patchwork Sun Sep 9 16:06:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Eggert X-Patchwork-Id: 29280 Received: (qmail 22692 invoked by alias); 9 Sep 2018 16:06:40 -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 22682 invoked by uid 89); 9 Sep 2018 16:06:40 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.2 spammy=maps, H*Ad:D*edu X-HELO: zimbra.cs.ucla.edu From: Paul Eggert To: libc-alpha@sourceware.org Cc: Paul Eggert Subject: [PATCH 2/2] Fix mktime localtime offset confusion Date: Sun, 9 Sep 2018 09:06:25 -0700 Message-Id: <20180909160625.15214-2-eggert@cs.ucla.edu> In-Reply-To: <20180909160625.15214-1-eggert@cs.ucla.edu> References: <20180909160625.15214-1-eggert@cs.ucla.edu> [BZ #23603] * include/time.h (__mktime_internal): The localtime offset is now of type long int instead of time_t. This is the longstanding type in glibc, and it is more than enough to represent difference between localtime and gmtime even if it is 32 bits and time_t is 64. Changing it now will let us avoid an unnecessary change when time_t is widened to 64 bits on 32-bit platforms. * time/mktime-internal.h (mktime_offset_t): Now long int. --- ChangeLog | 10 ++++++++++ include/time.h | 4 ++-- time/mktime-internal.h | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 68f6728290..874da4bee0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ 2018-09-09 Paul Eggert + Fix mktime localtime offset confusion + [BZ #23603] + * include/time.h (__mktime_internal): The localtime offset is now + of type long int instead of time_t. This is the longstanding type + in glibc, and it is more than enough to represent difference + between localtime and gmtime even if it is 32 bits and time_t is + 64. Changing it now will let us avoid an unnecessary change when + time_t is widened to 64 bits on 32-bit platforms. + * time/mktime-internal.h (mktime_offset_t): Now long int. + Merge mktime, timegm from upstream Gnulib [BZ #23603][BZ #16346] This fixes some obscure problems with integer overflow. diff --git a/include/time.h b/include/time.h index 23d2580528..e30c5fc3b1 100644 --- a/include/time.h +++ b/include/time.h @@ -55,11 +55,11 @@ extern void __tz_compute (time_t timer, struct tm *tm, int use_localtime) /* Subroutine of `mktime'. Return the `time_t' representation of TP and normalize TP, given that a `struct tm *' maps to a `time_t' as performed - by FUNC. Keep track of next guess for time_t offset in *OFFSET. */ + by FUNC. Record next guess for localtime-gmtime offset in *OFFSET. */ extern time_t __mktime_internal (struct tm *__tp, struct tm *(*__func) (const time_t *, struct tm *), - time_t *__offset) attribute_hidden; + long int *__offset) attribute_hidden; extern struct tm *__localtime_r (const time_t *__timer, struct tm *__tp) attribute_hidden; diff --git a/time/mktime-internal.h b/time/mktime-internal.h index ba1d9c7aab..cfd9127522 100644 --- a/time/mktime-internal.h +++ b/time/mktime-internal.h @@ -1 +1 @@ -typedef time_t mktime_offset_t; +typedef long int mktime_offset_t;