Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tag: 20120920
Fetching contributors…

Cannot retrieve contributors at this time

file 62 lines (60 sloc) 1.751 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
--- gzip-1.3.5.orig/gzip.c
+++ gzip-1.3.5/gzip.c
@@ -878,8 +878,11 @@
     }
 
     close(ifd);
- if (!to_stdout && close(ofd)) {
- write_error();
+ if (!to_stdout) {
+ /* Copy modes, times, ownership, and remove the input file */
+ copy_stat(&istat);
+ if (close(ofd))
+ write_error();
     }
     if (method == -1) {
  if (!to_stdout) xunlink (ofname);
@@ -899,10 +902,6 @@
  }
  fprintf(stderr, "\n");
     }
- /* Copy modes, times, ownership, and remove the input file */
- if (!to_stdout) {
- copy_stat(&istat);
- }
 }
 
 /* ========================================================================
@@ -1322,6 +1321,7 @@
  /* Copy the base name. Keep a directory prefix intact. */
                 char *p = base_name (ofname);
                 char *base = p;
+ char *base2;
  for (;;) {
  *p = (char)get_char();
  if (*p++ == '\0') break;
@@ -1329,6 +1329,8 @@
  error("corrupted input -- file name too large");
  }
  }
+ base2 = base_name (base);
+ strcpy(base, base2);
                 /* If necessary, adapt the name to local OS conventions: */
                 if (!list) {
                    MAKE_LEGAL_NAME(base);
@@ -1730,7 +1732,7 @@
     reset_times(ofname, ifstat);
 #endif
     /* Copy the protection modes */
- if (chmod(ofname, ifstat->st_mode & 07777)) {
+ if (fchmod(ofd, ifstat->st_mode & 07777)) {
  int e = errno;
  WARN((stderr, "%s: ", progname));
  if (!quiet) {
@@ -1739,7 +1741,7 @@
  }
     }
 #ifndef NO_CHOWN
- chown(ofname, ifstat->st_uid, ifstat->st_gid); /* Copy ownership */
+ (void) fchown(ofd, ifstat->st_uid, ifstat->st_gid); /* Copy ownership */
 #endif
     remove_ofname = 0;
     /* It's now safe to remove the input file: */
Something went wrong with that request. Please try again.