]> git.ipfire.org Git - thirdparty/tar.git/commitdiff
Fix savannah bug #60002
authorSergey Poznyakoff <gray@gnu.org>
Thu, 4 Feb 2021 14:51:38 +0000 (16:51 +0200)
committerSergey Poznyakoff <gray@gnu.org>
Thu, 4 Feb 2021 14:51:38 +0000 (16:51 +0200)
Bug was introduced by commit 34d15af1.

* src/extract.c (prepare_to_extract): When extracting over pipe,
process only regular files.
* tests/extrac24.at: New test case.
* tests/Makefile.am: Add new test case.
* tests/testsuite.at: Likewise.

po/.gitignore
src/extract.c
tests/Makefile.am
tests/extrac24.at [new file with mode: 0644]
tests/testsuite.at

index b434b10df6852467ffd8439f596dc31904a1ebe5..ba06fe329f32395d1e5d2bf0bca4fa4111ebc748 100644 (file)
@@ -1,3 +1,4 @@
+/Makefile.in.in
 /Makevars.template~
 /Makefile.in.in~
 *.gmo
index d6d98cb9a128a4abb7fea56969744b6bab9d3d12..4429a90b1f102575c07e59344df164a189bfa867 100644 (file)
@@ -1708,7 +1708,12 @@ prepare_to_extract (char const *file_name, int typeflag, tar_extractor_t *fun)
       extractor = extract_file;
     }
 
-  if (!EXTRACT_OVER_PIPE)
+  if (EXTRACT_OVER_PIPE)
+    {
+      if (extractor != extract_file)
+       return false;
+    }
+  else
     {
       switch (old_files_option)
        {
index b76fac9b6a93735d49d9dedb0ecd112016415e8f..2ee589c2e8103111b842f743bfac8e621a70f824 100644 (file)
@@ -122,6 +122,7 @@ TESTSUITE_AT = \
  extrac21.at\
  extrac22.at\
  extrac23.at\
+ extrac24.at\
  filerem01.at\
  filerem02.at\
  dirrem01.at\
diff --git a/tests/extrac24.at b/tests/extrac24.at
new file mode 100644 (file)
index 0000000..80cea54
--- /dev/null
@@ -0,0 +1,41 @@
+# Test suite for GNU tar.                             -*- autotest -*-
+# Copyright 2021 Free Software Foundation, Inc.
+#
+# This file is part of GNU tar.
+#
+# GNU tar is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# GNU tar is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+AT_SETUP([--to-stdout])
+AT_KEYWORDS([extract extrac24 to-stdout])
+
+# Description: When extracting over pipe, only regular files should be
+# extracted.  In tar 1.33 this was broken, so that members of other types
+# (in particular, directories) were extracted as usual.  This test ensures
+# that this is no longer the case.
+#
+# References: https://bugs.archlinux.org/task/69373,
+#             https://savannah.gnu.org/bugs/?60002
+
+AT_TAR_CHECK([
+mkdir dir/
+echo TEXT > dir/file
+tar cf a.tar dir
+rm -r dir
+tar --extract --to-stdout --file a.tar
+test -d dir
+],
+[1],
+[TEXT
+])
+
+AT_CLEANUP
index ef8519dece2ff41daece486d1f650827f6137c3b..d93f394c7e59a96e75672c09e43eb1d4666592d7 100644 (file)
@@ -344,6 +344,7 @@ m4_include([extrac20.at])
 m4_include([extrac21.at])
 m4_include([extrac22.at])
 m4_include([extrac23.at])
+m4_include([extrac24.at])
 
 m4_include([backup01.at])