]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
xz: Fix --force on setuid/setgid/sticky and multi-hardlink files.
authorLasse Collin <lasse.collin@tukaani.org>
Wed, 26 Jan 2011 10:19:08 +0000 (12:19 +0200)
committerLasse Collin <lasse.collin@tukaani.org>
Wed, 26 Jan 2011 10:19:08 +0000 (12:19 +0200)
xz didn't compress setuid/setgid/sticky files and files
with multiple hard links even with --force. This bug was
introduced in 23ac2c44c3ac76994825adb7f9a8f719f78b5ee4.

Thanks to Charles Wilson.

src/xz/file_io.c

index 6e24c58a945c8b9360fa6a6ca8565d30c7eb4bec..09edcca69eb40cd57ae4f1c1e56410807ad421bd 100644 (file)
@@ -457,15 +457,14 @@ io_open_src_real(file_pair *pair)
                goto error;
        }
 
-       if (reg_files_only) {
-               if (!S_ISREG(pair->src_st.st_mode)) {
-                       message_warning(_("%s: Not a regular file, "
-                                       "skipping"), pair->src_name);
-                       goto error;
-               }
+       if (reg_files_only && !S_ISREG(pair->src_st.st_mode)) {
+               message_warning(_("%s: Not a regular file, skipping"),
+                               pair->src_name);
+               goto error;
+       }
 
-               // These are meaningless on Windows.
 #ifndef TUKLIB_DOSLIKE
+       if (reg_files_only && !opt_force) {
                if (pair->src_st.st_mode & (S_ISUID | S_ISGID)) {
                        // gzip rejects setuid and setgid files even
                        // when --force was used. bzip2 doesn't check
@@ -495,8 +494,8 @@ io_open_src_real(file_pair *pair)
                                        "skipping"), pair->src_name);
                        goto error;
                }
-#endif
        }
+#endif
 
        return false;