From unknown Sat Jun 21 05:00:22 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#24385 <24385@debbugs.gnu.org> To: bug#24385 <24385@debbugs.gnu.org> Subject: Status: [INSTALLED PATCH] gzip: fix some Y2038 etc. bugs Reply-To: bug#24385 <24385@debbugs.gnu.org> Date: Sat, 21 Jun 2025 12:00:22 +0000 retitle 24385 [INSTALLED PATCH] gzip: fix some Y2038 etc. bugs reassign 24385 gzip submitter 24385 Paul Eggert severity 24385 normal tag 24385 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 06 17:54:20 2016 Received: (at submit) by debbugs.gnu.org; 6 Sep 2016 21:54:21 +0000 Received: from localhost ([127.0.0.1]:51765 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bhOJw-0004ic-KS for submit@debbugs.gnu.org; Tue, 06 Sep 2016 17:54:20 -0400 Received: from eggs.gnu.org ([208.118.235.92]:57935) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bhOJu-0004iP-VK for submit@debbugs.gnu.org; Tue, 06 Sep 2016 17:54:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bhOJm-0004Y8-9A for submit@debbugs.gnu.org; Tue, 06 Sep 2016 17:54:13 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:55652) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhOJm-0004Xy-68 for submit@debbugs.gnu.org; Tue, 06 Sep 2016 17:54:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48835) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhOJf-0001jz-QT for bug-gzip@gnu.org; Tue, 06 Sep 2016 17:54:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bhOJb-0004WO-Mk for bug-gzip@gnu.org; Tue, 06 Sep 2016 17:54:02 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:35548) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhOJb-0004WH-CW for bug-gzip@gnu.org; Tue, 06 Sep 2016 17:53:59 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 969DB161123 for ; Tue, 6 Sep 2016 14:53:58 -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 JYe3xoU5ikYn; Tue, 6 Sep 2016 14:53:57 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 5284B16111A; Tue, 6 Sep 2016 14:53:57 -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 VYIZTAQB_U3t; Tue, 6 Sep 2016 14:53:57 -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 30D7C160D1E; Tue, 6 Sep 2016 14:53:57 -0700 (PDT) From: Paul Eggert To: bug-gzip@gnu.org Subject: [INSTALLED PATCH] gzip: fix some Y2038 etc. bugs Date: Tue, 6 Sep 2016 14:53:53 -0700 Message-Id: <1473198833-15112-1-git-send-email-eggert@cs.ucla.edu> X-Mailer: git-send-email 2.7.4 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit Cc: Paul Eggert X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) * NEWS: Document this. * gzip.c (get_method): Warn about out-of-range MTIME, and ignore it instead of relying on possibly-undefined behavior. * tests/Makefile.am (TESTS): Add timestamp. * tests/timestamp: New test. * zip.c (zip): Warn about out-of-range file time stamp. --- NEWS | 6 ++++++ gzip.c | 11 +++++++++-- tests/Makefile.am | 1 + tests/timestamp | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ zip.c | 12 +++++++++--- 5 files changed, 77 insertions(+), 5 deletions(-) create mode 100755 tests/timestamp diff --git a/NEWS b/NEWS index 8c81f5c..6532550 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,12 @@ GNU gzip NEWS -*- outline -*- ** Bug fixes + gzip now warns about file time stamps out of gzip range, or out of + time_t range, instead of silently continuing, sometimes with + undefined behavior. This affects time stamps before 1970 or after + 2106, and time stamps after 2038 on 32-bit platforms. + [bug present since the beginning] + Support for VMS and Amiga has been removed. It was not working anyway, and it reportedly caused file name glitches on MS-Windowsish platforms. diff --git a/gzip.c b/gzip.c index 0d0953c..0fca5a3 100644 --- a/gzip.c +++ b/gzip.c @@ -1537,8 +1537,15 @@ local int get_method(in) stamp |= ((ulg)get_byte()) << 24; if (stamp != 0 && !no_time) { - time_stamp.tv_sec = stamp; - time_stamp.tv_nsec = 0; + if (stamp <= TYPE_MAXIMUM (time_t)) + { + time_stamp.tv_sec = stamp; + time_stamp.tv_nsec = 0; + } + else + WARN ((stderr, + "%s: %s: MTIME %lu out of range for this platform\n", + program_name, ifname, stamp)); } magic[8] = get_byte (); /* Ignore extra flags. */ diff --git a/tests/Makefile.am b/tests/Makefile.am index 71cf4ad..1c24886 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -25,6 +25,7 @@ TESTS = \ mixed \ null-suffix-clobber \ stdin \ + timestamp \ trailing-nul \ unpack-invalid \ z-suffix \ diff --git a/tests/timestamp b/tests/timestamp new file mode 100755 index 0000000..c488760 --- /dev/null +++ b/tests/timestamp @@ -0,0 +1,52 @@ +#!/bin/sh +# Exercise timestamps. + +# Copyright 2016 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program 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 General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# limit so don't run it by default. + +. "${srcdir=.}/init.sh"; path_prepend_ .. + +TZ=UTC0 +export TZ + +# On platforms supporting time stamps outside gzip's range, +# test that gzip warns when converting them to gzip format. +for time in 190101010000 196912312359.59 197001010000 210602070628.16; do + if touch -t $time in; then + gzip in + test $? = 2 || fail=1 + fi + rm -f in in.gz +done + +# Test that time stamps in range for gzip do not generate warnings. +for time in 197001010000.01 203801190314.07 203801190314.08 210602070628.15; do + if touch -t $time in; then + gzip in || fail=1 + fi + rm -f in in.gz +done + +# On platforms that fail to support time stamps within gzip's range, +# test that gzip warns when converting them from gzip format. +touch -t 210602070628.15 in || { + printf '\037\213\10\0\377\377\377\377\0\377\3\0\0\0\0\0\0\0\0\0' >y2106.gz || + framework_failure_ + gzip -Nlv ) id 1bhOLS-0004lC-2p for submit@debbugs.gnu.org; Tue, 06 Sep 2016 17:55:54 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:47438) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bhOLP-0004kx-TB for control@debbugs.gnu.org; Tue, 06 Sep 2016 17:55:52 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id DD9C7160195 for ; Tue, 6 Sep 2016 14:55:45 -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 1eXy-YAAsmii for ; Tue, 6 Sep 2016 14:55:45 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 485C7160D1E for ; Tue, 6 Sep 2016 14:55:45 -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 J9MmN1PLQTBv for ; Tue, 6 Sep 2016 14:55:45 -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 336E2160195 for ; Tue, 6 Sep 2016 14:55:45 -0700 (PDT) To: control@debbugs.gnu.org From: Paul Eggert Subject: 24385 is fixed already Organization: UCLA Computer Science Department Message-ID: <2472d4cb-e954-6178-6541-44b743639869@cs.ucla.edu> Date: Tue, 6 Sep 2016 14:55:45 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -1.1 (-) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.1 (-) close 24385 From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 07 17:58:35 2016 Received: (at 24385) by debbugs.gnu.org; 7 Sep 2016 21:58:35 +0000 Received: from localhost ([127.0.0.1]:52933 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bhkra-0005vk-RL for submit@debbugs.gnu.org; Wed, 07 Sep 2016 17:58:34 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:37188) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bhkrZ-0005vX-4P for 24385@debbugs.gnu.org; Wed, 07 Sep 2016 17:58:33 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 2313716119A for <24385@debbugs.gnu.org>; Wed, 7 Sep 2016 14:58:26 -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 dUpnB6HNbUx9; Wed, 7 Sep 2016 14:58:25 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 5D623161198; Wed, 7 Sep 2016 14:58:25 -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 ayLMcFt0D_Ec; Wed, 7 Sep 2016 14:58:25 -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 497B2161172; Wed, 7 Sep 2016 14:58:25 -0700 (PDT) From: Paul Eggert To: 24385@debbugs.gnu.org Subject: [PATCH] * doc/gzip.texi: Fix off-by-one timestamp. Date: Wed, 7 Sep 2016 14:58:09 -0700 Message-Id: <1473285489-26545-1-git-send-email-eggert@cs.ucla.edu> X-Mailer: git-send-email 2.7.4 X-Spam-Score: -1.1 (-) X-Debbugs-Envelope-To: 24385 Cc: Paul Eggert X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.1 (-) --- doc/gzip.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/gzip.texi b/doc/gzip.texi index c63a892..478c4e4 100644 --- a/doc/gzip.texi +++ b/doc/gzip.texi @@ -104,7 +104,7 @@ the compressed file. These are used when decompressing the file with the truncated or when the time stamp was not preserved after a file transfer. However, due to limitations in the current @command{gzip} file format, fractional seconds are discarded. Also, time stamps must fall -within the range 1970-01-01 00:00:00 through 2106-02-07 06:28:15 +within the range 1970-01-01 00:00:01 through 2106-02-07 06:28:15 @abbr{UTC}, and hosts whose operating systems use 32-bit time stamps are further restricted to time stamps no later than 2038-01-19 03:14:07 @abbr{UTC}. The upper bounds assume the typical case -- 2.7.4 From unknown Sat Jun 21 05:00:22 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 06 Oct 2016 11:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator