1 fix CAN-2005-0988 race condition when setting file permissions
4 --- gzip-1.3.5/gzip.c.perm 2005-04-26 14:22:58.211395152 +0200
5 +++ gzip-1.3.5/gzip.c 2005-04-26 14:24:10.414418624 +0200
10 + /* ofd ownership and permissions have to be set before close(ofd)*/
12 + if (fchmod(ofd, istat.st_mode & 07777)) {
14 + WARN((stderr, "%s: ", progname));
21 + fchown(ofd, istat.st_uid, istat.st_gid); /* Copy ownership */
24 if (!to_stdout && close(ofd)) {
29 fprintf(stderr, "\n");
31 - /* Copy modes, times, ownership, and remove the input file */
32 + /* Copy times and remove the input file */
39 /* ========================================================================
40 - * Copy modes, times, ownership from input file to output file.
41 + * Copy times from input file to output file.
42 * IN assertion: to_stdout is false.
44 local void copy_stat(ifstat)
45 @@ -1730,18 +1744,6 @@
47 reset_times(ofname, ifstat);
49 - /* Copy the protection modes */
50 - if (chmod(ofname, ifstat->st_mode & 07777)) {
52 - WARN((stderr, "%s: ", progname));
59 - chown(ofname, ifstat->st_uid, ifstat->st_gid); /* Copy ownership */
62 /* It's now safe to remove the input file: */
63 if (xunlink (ifname)) {