zgz: Avoid using uninitialized data as timestamp in -c mode. Closes: #507095
authorJoey Hess <joey@kodama.kitenet.net>
Wed, 3 Dec 2008 19:56:45 +0000 (14:56 -0500)
committerJoey Hess <joey@kodama.kitenet.net>
Wed, 3 Dec 2008 19:56:45 +0000 (14:56 -0500)
debian/changelog
zgz.c

index a259f400903ecfa6e475eae8f4e4f9f3b9c8e8c0..87c36a62f58a4a9cecc0b18b457d0993b3b2c8d7 100644 (file)
@@ -1,5 +1,6 @@
-pristine-tar (0.19) unstable; urgency=low
+pristine-tar (0.19) UNRELEASED; urgency=low
 
+  [ Josh Triplett ]
   * Add a .gitignore file
   * Various cleanups to zgz.
   * Remove the unnecessary -l, -S, -t, and -v flags from zgz.
@@ -10,6 +11,10 @@ pristine-tar (0.19) unstable; urgency=low
     stored in the gzip file, rather than taking the timestamp of the input
     file. Closes: #507110
 
+  [ Joey Hess ]
+  * zgz: Avoid using uninitialized data as timestamp in -c mode.
+    Closes: #507095
+
  -- Josh Triplett <josh@freedesktop.org>  Thu, 27 Nov 2008 19:54:29 -0800
 
 pristine-tar (0.18) unstable; urgency=low
diff --git a/zgz.c b/zgz.c
index f58bfe95e41cf8fe603646202ef5520a80e755a0..10d13cbba68724f69cbfdde89647a11c6813e7cd 100644 (file)
--- a/zgz.c
+++ b/zgz.c
@@ -667,17 +667,20 @@ file_compress(char *file, char *origname, char *outfile, size_t outsize)
                maybe_warn("can't open %s", file);
                return -1;
        }
+               
+       if (fstat(in, &isb) != 0) {
+               maybe_warn("can't fstat %s", file);
+               return -1;
+       }
 
        if (cflag == 0) {
-               if (fstat(in, &isb) == 0) {
-                       if (isb.st_nlink > 1 && fflag == 0) {
-                               maybe_warnx("%s has %lu other link%s -- "
-                                           "skipping", file,
-                                           (unsigned long)(isb.st_nlink - 1),
-                                           isb.st_nlink == 1 ? "" : "s");
-                               close(in);
-                               return -1;
-                       }
+               if (isb.st_nlink > 1 && fflag == 0) {
+                       maybe_warnx("%s has %lu other link%s -- "
+                                   "skipping", file,
+                                   (unsigned long)(isb.st_nlink - 1),
+                                   isb.st_nlink == 1 ? "" : "s");
+                       close(in);
+                       return -1;
                }
 
                if (fflag == 0 && (suff = check_suffix(file, 0))