gzip: fix some Y2038 etc. bugs
[debian/gzip] / zip.c
diff --git a/zip.c b/zip.c
index 7f1117c5d23b35c328df395a1d09116d5920f782..eb60409c7edc1851f31671921ba9d09806c1bb6f 100644 (file)
--- a/zip.c
+++ b/zip.c
@@ -23,9 +23,6 @@
 #include "tailor.h"
 #include "gzip.h"
 
-#include <unistd.h>
-#include <fcntl.h>
-
 local ulg crc;       /* crc on uncompressed file data */
 off_t header_bytes;   /* number of bytes in gzip header */
 
@@ -57,9 +54,15 @@ int zip(in, out)
         flags |= ORIG_NAME;
     }
     put_byte(flags);         /* general flags */
-    stamp = (0 <= time_stamp.tv_sec && time_stamp.tv_sec <= 0xffffffff
-             ? (ulg) time_stamp.tv_sec
-             : (ulg) 0);
+    if (0 < time_stamp.tv_sec && time_stamp.tv_sec <= 0xffffffff)
+      stamp = time_stamp.tv_sec;
+    else
+      {
+        /* It's intended that time stamp 0 generates this warning,
+           since gzip format reserves 0 for something else.  */
+        warning ("file time stamp out of range for gzip format");
+        stamp = 0;
+      }
     put_long (stamp);
 
     /* Write deflated file to zip file */
@@ -83,8 +86,8 @@ int zip(in, out)
     (void)deflate();
 
 #ifndef NO_SIZE_CHECK
-  /* Check input size (but not in VMS -- variable record lengths mess it up)
-   * and not on MSDOS -- diet in TSR mode reports an incorrect file size)
+  /* Check input size
+   * (but not on MSDOS -- diet in TSR mode reports an incorrect file size)
    */
     if (ifile_size != -1L && bytes_in != ifile_size) {
         fprintf(stderr, "%s: %s: file size changed while zipping\n",