From patchwork Tue Sep 14 05:49:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Eggert X-Patchwork-Id: 44970 X-Patchwork-Delegate: azanella@linux.vnet.ibm.com Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E80053857C6F for ; Tue, 14 Sep 2021 05:50:09 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id 4939F3858402 for ; Tue, 14 Sep 2021 05:49:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4939F3858402 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=cs.ucla.edu Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=cs.ucla.edu Received: from fencepost.gnu.org ([2001:470:142:3::e]:41812) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQ1KP-00030r-OQ for libc-alpha@sourceware.org; Tue, 14 Sep 2021 01:49:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44550) by fencepost.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ1KP-0001Ta-LP for libc-alpha@gnu.org; Tue, 14 Sep 2021 01:49:57 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:40306) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ1KO-0002xS-10 for libc-alpha@gnu.org; Tue, 14 Sep 2021 01:49:57 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 46398160134 for ; Mon, 13 Sep 2021 22:49:52 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 9d9s3KaIuP-Q; Mon, 13 Sep 2021 22:49:51 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 69EA816012F; Mon, 13 Sep 2021 22:49:51 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 5JmRMTKgMkv0; Mon, 13 Sep 2021 22:49:51 -0700 (PDT) Received: from penguin.cs.ucla.edu (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 5266E1600E5; Mon, 13 Sep 2021 22:49:51 -0700 (PDT) From: Paul Eggert To: libc-alpha@gnu.org Subject: [PATCH] Fix subscript error with odd TZif file [BZ #28338] Date: Mon, 13 Sep 2021 22:49:45 -0700 Message-Id: <20210914054946.46372-1-eggert@cs.ucla.edu> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Received-SPF: pass client-ip=131.179.128.68; envelope-from=eggert@cs.ucla.edu; helo=zimbra.cs.ucla.edu X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Status: No, score=-19.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" * time/tzfile.c (__tzfile_compute): Fix unlikely off-by-one bug that accessed before start of an array when an oddball-but-valid TZif file was queried with an unusual time_t value. Reviewed-by: Adhemerval Zanella --- time/tzfile.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/time/tzfile.c b/time/tzfile.c index 4377018a55..190a777152 100644 --- a/time/tzfile.c +++ b/time/tzfile.c @@ -765,8 +765,7 @@ __tzfile_compute (__time64_t timer, int use_localtime, *leap_correct = leaps[i].change; if (timer == leaps[i].transition /* Exactly at the transition time. */ - && ((i == 0 && leaps[i].change > 0) - || leaps[i].change > leaps[i - 1].change)) + && (leaps[i].change > (i == 0 ? 0 : leaps[i - 1].change))) { *leap_hit = 1; while (i > 0