Skip site navigation (1)Skip section navigation (2)
Date:      Tue,  1 Jun 2010 12:01:17 +0200 (CEST)
From:      Thomas Quinot <thomas@cuivre.fr.eu.org>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   bin/147275: gzip -c <file> does not save original time stamp
Message-ID:  <20100601100117.436725E26@melamine.cuivre.fr.eu.org>
Resent-Message-ID: <201006011010.o51AA245073935@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         147275
>Category:       bin
>Synopsis:       gzip -c <file> does not save original time stamp
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jun 01 10:10:02 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator:     Thomas Quinot
>Release:        FreeBSD 8.0-STABLE amd64
>Organization:
>Environment:
System: FreeBSD melamine.cuivre.fr.eu.org 8.0-STABLE FreeBSD 8.0-STABLE #0: Sun Mar 28 14:46:11 CEST 2010 thomas@melamine.cuivre.fr.eu.org:/usr/obj/usr/src/sys/GENERIC amd64


	
>Description:
	When a file name is provided on the command line, gzip -c does not
	save its timestamp in the output compressed stream.
>How-To-Repeat:
	cd /tmp
	touch foo
	gzip -c foo > foo1.gz
	gzip foo
	file foo1.gz foo.gz

foo1.gz: gzip compressed data, was "foo", from Unix
foo.gz:  gzip compressed data, was "foo", from Unix, last modified: Tue Jun  1 11:55:30 2010

>Fix:

Index: gzip.c
===================================================================
--- gzip.c	(révision 208689)
+++ gzip.c	(copie de travail)
@@ -1212,6 +1212,7 @@
 {
 	int in;
 	int out;
+	int rc;
 	off_t size, insize;
 #ifndef SMALL
 	struct stat isb, osb;
@@ -1224,9 +1225,16 @@
 		return -1;
 	}
 
+	/* Stat input file even in stdout (-c) mode so that the
+	 * correct time stamp is inserted in the compressed
+	 * output stream.
+	 */
+
+	rc = fstat (in, &isb);
+
 	if (cflag == 0) {
 #ifndef SMALL
-		if (fstat(in, &isb) == 0) {
+		if (rc == 0) {
 			if (isb.st_nlink > 1 && fflag == 0) {
 				maybe_warnx("%s has %d other link%s -- "
 					    "skipping", file, isb.st_nlink - 1,


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100601100117.436725E26>