aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Felker <dalias@libc.org>2015-02-02 16:01:16 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2015-02-02 16:01:16 +0100
commit7f7ade1964f61172125d9f4fe92f0b07ce8bc7a4 (patch)
treefadfa1f6df6012bdb4f1cebe6fc956aac92e0f83
parent5104645cf87f8cf37c42666c90bb259011cfac58 (diff)
downloadbusybox-7f7ade1964f61172125d9f4fe92f0b07ce8bc7a4.tar.gz
gzip: do not store timestamp in gzip header
Storing the original file's modification time in the output file is harmful (precludes deterministic results) and unlike official gzip, the busybox version provides no way to suppress this behavior; the -n option is silently ignored. Rather than trying to make -n work, this patch just removes the timestamp-storing functionality. It should be considered deprecated anyway; it's not Y2038-safe and gunzip ignores it by default. Per RFC 1952, 0 is the correct value to store to indicate that there is no timestamp. Signed-off-by: Rich Felker <dalias@libc.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--archival/gzip.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/archival/gzip.c b/archival/gzip.c
index a93d2175a..46367f9e6 100644
--- a/archival/gzip.c
+++ b/archival/gzip.c
@@ -2007,7 +2007,7 @@ static void ct_init(void)
* IN assertions: the input and output buffers are cleared.
*/
-static void zip(ulg time_stamp)
+static void zip(void)
{
ush deflate_flags = 0; /* pkzip -es, -en or -ex equivalent */
@@ -2018,7 +2018,7 @@ static void zip(ulg time_stamp)
/* compression method: 8 (DEFLATED) */
/* general flags: 0 */
put_32bit(0x00088b1f);
- put_32bit(time_stamp);
+ put_32bit(0); /* Unix timestamp */
/* Write deflated file to zip file */
G1.crc = ~0;
@@ -2044,8 +2044,6 @@ static void zip(ulg time_stamp)
static
IF_DESKTOP(long long) int FAST_FUNC pack_gzip(transformer_state_t *xstate UNUSED_PARAM)
{
- struct stat s;
-
/* Clear input and output buffers */
G1.outcnt = 0;
#ifdef DEBUG
@@ -2077,9 +2075,23 @@ IF_DESKTOP(long long) int FAST_FUNC pack_gzip(transformer_state_t *xstate UNUSED
G2.bl_desc.max_length = MAX_BL_BITS;
//G2.bl_desc.max_code = 0;
+#if 0
+ /* Saving of timestamp is disabled. Why?
+ * - it is not Y2038-safe.
+ * - some people want deterministic results
+ * (normally they'd use -n, but our -n is a nop).
+ * - it's bloat.
+ * Per RFC 1952, gzfile.time=0 is "no timestamp".
+ * If users will demand this to be reinstated,
+ * implement -n "don't save timestamp".
+ */
+ struct stat s;
s.st_ctime = 0;
fstat(STDIN_FILENO, &s);
zip(s.st_ctime);
+#else
+ zip();
+#endif
return 0;
}