[tar/f13/master] match non-stripped file names (#637085)

Kamil Dudka kdudka at fedoraproject.org
Fri Sep 24 13:32:34 UTC 2010


commit 62a0214eabf11772b2aaddfd5aeb4e5df8124b7a
Author: Kamil Dudka <kdudka at redhat.com>
Date:   Fri Sep 24 15:12:05 2010 +0200

    match non-stripped file names (#637085)

 tar-1.22-stripcomponents.patch |  161 ++++++++++++++++++++++++++++++++++++++++
 tar.spec                       |   10 ++-
 2 files changed, 169 insertions(+), 2 deletions(-)
---
diff --git a/tar-1.22-stripcomponents.patch b/tar-1.22-stripcomponents.patch
new file mode 100644
index 0000000..35e4f3a
--- /dev/null
+++ b/tar-1.22-stripcomponents.patch
@@ -0,0 +1,161 @@
+From: Kamil Dudka <kdudka at redhat.com>
+Date: Fri, 24 Sep 2010 14:16:04 +0200
+Subject: [PATCH] tar: match non-stripped file names
+
+* src/common.h: Declare of transform_name_from_header().
+* src/list.c (read_and): Match non-stripped file names.
+(transform_name_from_header): Detached part of code of decode_header().
+* src/update.c (update_archive): Avoid any change in behavior here.
+* tests/exclude07.at: New test case.
+* tests/testsuite.at: Include exclude07.at.
+* tests/Makefile.am (TESTSUITE_AT): Add exclude07.at.
+---
+ src/common.h       |    1 +
+ src/list.c         |   12 ++++++++++--
+ src/update.c       |    1 +
+ tests/Makefile.am  |    1 +
+ tests/exclude07.at |   42 ++++++++++++++++++++++++++++++++++++++++++
+ tests/testsuite.at |    1 +
+ 6 files changed, 56 insertions(+), 2 deletions(-)
+
+diff --git a/src/common.h b/src/common.h
+index 5318279..b3e7065 100644
+--- a/src/common.h
++++ b/src/common.h
+@@ -536,6 +536,7 @@ extern size_t recent_long_link_blocks;
+ 
+ void decode_header (union block *header, struct tar_stat_info *stat_info,
+ 		    enum archive_format *format_pointer, int do_user_group);
++void transform_name_from_header(union block *header, struct tar_stat_info *);
+ char const *tartime (struct timespec t, bool full_time);
+ 
+ #define GID_FROM_HEADER(where) gid_from_header (where, sizeof (where))
+diff --git a/src/list.c b/src/list.c
+index 2bbfe73..b995343 100644
+--- a/src/list.c
++++ b/src/list.c
+@@ -74,6 +74,7 @@ read_and (void (*do_something) (void))
+   open_archive (ACCESS_READ);
+   do
+     {
++      bool skip;
+       prev_status = status;
+       tar_stat_destroy (&current_stat_info);
+ 
+@@ -90,7 +91,7 @@ read_and (void (*do_something) (void))
+ 	     Ensure incoming names are null terminated.  */
+ 	  decode_header (current_header, &current_stat_info,
+ 			 &current_format, 1);
+-	  if (! name_match (current_stat_info.file_name)
++	  skip = (! name_match (current_stat_info.file_name)
+ 	      || (NEWER_OPTION_INITIALIZED (newer_mtime_option)
+ 		  /* FIXME: We get mtime now, and again later; this causes
+ 		     duplicate diagnostics if header.mtime is bogus.  */
+@@ -101,7 +102,10 @@ read_and (void (*do_something) (void))
+ 		      mtime.tv_nsec = 0,
+ 		      current_stat_info.mtime = mtime,
+ 		      OLDER_TAR_STAT_TIME (current_stat_info, m)))
+-	      || excluded_name (current_stat_info.file_name))
++	      || excluded_name (current_stat_info.file_name));
++
++	  transform_name_from_header (current_header, &current_stat_info);
++	  if (skip)
+ 	    {
+ 	      switch (current_header->header.typeflag)
+ 		{
+@@ -641,7 +645,11 @@ decode_header (union block *header, struct tar_stat_info *stat_info,
+           || stat_info->dumpdir)
+ 	stat_info->is_dumpdir = true;
+     }
++}
+ 
++void
++transform_name_from_header(union block *header, struct tar_stat_info *stat_info)
++{
+   transform_member_name (&stat_info->file_name, XFORM_REGFILE);
+   switch (header->header.typeflag)
+     {
+diff --git a/src/update.c b/src/update.c
+index fa16193..ace7104 100644
+--- a/src/update.c
++++ b/src/update.c
+@@ -128,6 +128,7 @@ update_archive (void)
+ 
+ 	    decode_header (current_header, &current_stat_info,
+ 			   &current_format, 0);
++	    transform_name_from_header (current_header, &current_stat_info);
+ 	    archive_format = current_format;
+ 
+ 	    if (subcommand_option == UPDATE_SUBCOMMAND
+diff --git a/tests/Makefile.am b/tests/Makefile.am
+index 735a71d..ea76f9a 100644
+--- a/tests/Makefile.am
++++ b/tests/Makefile.am
+@@ -61,6 +61,7 @@ TESTSUITE_AT = \
+  delete05.at\
+  exclude.at\
+  exclude06.at\
++ exclude07.at\
+  extrac01.at\
+  extrac02.at\
+  extrac03.at\
+diff --git a/tests/exclude07.at b/tests/exclude07.at
+new file mode 100644
+index 0000000..ad376aa
+--- /dev/null
++++ b/tests/exclude07.at
+@@ -0,0 +1,42 @@
++# Process this file with autom4te to create testsuite. -*- Autotest -*-
++# Copyright (C) 2010 Free Software Foundation, Inc.
++
++# This program 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, or (at your option)
++# any later version.
++
++# This program 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/>.
++
++# upstream tar from 14efeb9f956e38d7beaf3fbedb04d3f3bb9ece3a fails to exclude
++# files by stripped part of path by  --strip-components
++#
++# Reported-by: Darius Ivanauskas
++# References: https://bugzilla.redhat.com/637085
++
++AT_SETUP([exclude: stripped part of path])
++AT_KEYWORDS([exclude exclude07])
++
++AT_TAR_CHECK([
++mkdir foo bar
++genfile --length 20 -f foo/file1
++genfile --length 20 -f foo/file2
++genfile --length 20 -f foo/file3
++genfile --length 20 -f bar/file4
++
++tar cf archive.tar foo bar
++mkdir out
++tar -C out -xf archive.tar --strip-components=1 bar/
++find out -type f
++],
++[0],
++[out/file4]
++)
++
++AT_CLEANUP
+diff --git a/tests/testsuite.at b/tests/testsuite.at
+index 9e8c1db..03099b2 100644
+--- a/tests/testsuite.at
++++ b/tests/testsuite.at
+@@ -124,6 +124,7 @@ m4_include([append02.at])
+ 
+ m4_include([exclude.at])
+ m4_include([exclude06.at])
++m4_include([exclude07.at])
+ 
+ m4_include([delete01.at])
+ m4_include([delete02.at])
diff --git a/tar.spec b/tar.spec
index 7157a14..cbe5c5f 100644
--- a/tar.spec
+++ b/tar.spec
@@ -5,7 +5,7 @@ Summary: A GNU file archiving program
 Name: tar
 Epoch: 2
 Version: 1.22
-Release: 18%{?dist}
+Release: 19%{?dist}
 License: GPLv3+
 Group: Applications/Archiving
 URL: http://www.gnu.org/software/tar/
@@ -46,6 +46,8 @@ Patch12: tar-1.22-exclusion-tags.patch
 Patch13: tar-1.22-segfault-incompletearchive.patch
 #fix exclusion of long file names with --xattrs (#634866)
 Patch14: tar-1.22-longnames.patch
+#match non-stripped file names (#637085)
+Patch15: tar-1.22-stripcomponents.patch
 Requires: info
 BuildRequires: autoconf automake gzip texinfo gettext libacl-devel gawk rsh
 %if %{WITH_SELINUX}
@@ -83,6 +85,7 @@ the rmt package.
 %patch12 -p1 -b .exclude
 %patch13 -p1 -b .incomplete
 %patch14 -p1 -b .longnames
+%patch15 -p1 -b .stripcomponents
 
 autoreconf
 
@@ -129,7 +132,7 @@ fi
 
 %files -f %{name}.lang
 %defattr(-,root,root)
-%doc AUTHORS ChangeLog ChangeLog.1 NEWS README THANKS TODO
+%doc AUTHORS ChangeLog ChangeLog.1 COPYING NEWS README THANKS TODO
 %ifos linux
 /bin/tar
 /bin/gtar
@@ -144,6 +147,9 @@ fi
 %{_infodir}/tar.info*
 
 %changelog
+* Fri Sep 24 2010 Kamil Dudka <kdudka at redhat.com> 2:1.22-19
+- match non-stripped file names (#637085)
+
 * Mon Sep 20 2010 Kamil Dudka <kdudka at redhat.com> 2:1.22-18
 - fix exclusion of long file names with --xattrs (#634866)
 


More information about the scm-commits mailing list