[tar/f20] options: fix --verify & --list segfault
Pavel Raiskup
praiskup at fedoraproject.org
Tue Apr 1 20:28:15 UTC 2014
commit 73bbdbfad2284043fe6bd13392e34c2a6abe8359
Author: Pavel Raiskup <praiskup at redhat.com>
Date: Tue Apr 1 22:26:03 2014 +0200
options: fix --verify & --list segfault
Resolves: #977807
Version: 1.26-31
tar-1.26-list-and-verify-segfault.patch | 400 +++++++++++++++++++++++++++++++
tar.spec | 8 +
2 files changed, 408 insertions(+), 0 deletions(-)
---
diff --git a/tar-1.26-list-and-verify-segfault.patch b/tar-1.26-list-and-verify-segfault.patch
new file mode 100644
index 0000000..62b774f
--- /dev/null
+++ b/tar-1.26-list-and-verify-segfault.patch
@@ -0,0 +1,400 @@
+diff --git a/src/common.h b/src/common.h
+index 2defe02..e00a04f 100644
+--- a/src/common.h
++++ b/src/common.h
+@@ -91,11 +91,6 @@ enum subcommand
+
+ GLOBAL enum subcommand subcommand_option;
+
+-#define READ_LIKE_SUBCOMMAND \
+- (subcommand_option == EXTRACT_SUBCOMMAND \
+- || subcommand_option == DIFF_SUBCOMMAND \
+- || subcommand_option == LIST_SUBCOMMAND)
+-
+ /* Selected format for output archive. */
+ GLOBAL enum archive_format archive_format;
+
+diff --git a/src/tar.c b/src/tar.c
+index 18277e4..5f80b6f 100644
+--- a/src/tar.c
++++ b/src/tar.c
+@@ -2291,7 +2291,31 @@ static const char *tar_authors[] = {
+ "Jay Fenlason",
+ NULL
+ };
++
++/* Subcommand classes */
++#define SUBCL_READ 0x01 /* subcommand reads from the archive */
++#define SUBCL_WRITE 0x02 /* subcommand writes to the archive */
++#define SUBCL_UPDATE 0x04 /* subcommand updates existing archive */
++#define SUBCL_TEST 0x08 /* subcommand tests archive header or meta-info */
++#define SUBCL_OCCUR 0x10 /* subcommand allows the use of the occurrence
++ option */
+
++static int subcommand_class[] = {
++ /* UNKNOWN_SUBCOMMAND */ 0,
++ /* APPEND_SUBCOMMAND */ SUBCL_WRITE|SUBCL_UPDATE,
++ /* CAT_SUBCOMMAND */ SUBCL_WRITE,
++ /* CREATE_SUBCOMMAND */ SUBCL_WRITE,
++ /* DELETE_SUBCOMMAND */ SUBCL_WRITE|SUBCL_UPDATE|SUBCL_OCCUR,
++ /* DIFF_SUBCOMMAND */ SUBCL_READ|SUBCL_OCCUR,
++ /* EXTRACT_SUBCOMMAND */ SUBCL_READ|SUBCL_OCCUR,
++ /* LIST_SUBCOMMAND */ SUBCL_READ|SUBCL_OCCUR,
++ /* UPDATE_SUBCOMMAND */ SUBCL_WRITE|SUBCL_UPDATE,
++ /* TEST_LABEL_SUBCOMMAND */ SUBCL_TEST
++};
++
++/* Return t if the subcommand_option is in class(es) f */
++#define IS_SUBCOMMAND_CLASS(f) (subcommand_class[subcommand_option] & (f))
++
+ static void
+ decode_options (int argc, char **argv)
+ {
+@@ -2455,12 +2479,10 @@ decode_options (int argc, char **argv)
+ if (!args.input_files)
+ USAGE_ERROR ((0, 0,
+ _("--occurrence is meaningless without a file list")));
+- if (subcommand_option != DELETE_SUBCOMMAND
+- && subcommand_option != DIFF_SUBCOMMAND
+- && subcommand_option != EXTRACT_SUBCOMMAND
+- && subcommand_option != LIST_SUBCOMMAND)
+- USAGE_ERROR ((0, 0,
+- _("--occurrence cannot be used in the requested operation mode")));
++ if (!IS_SUBCOMMAND_CLASS (SUBCL_OCCUR))
++ USAGE_ERROR ((0, 0,
++ _("--occurrence cannot be used with %s"),
++ subcommand_string (subcommand_option)));
+ }
+
+ if (archive_names == 0)
+@@ -2519,15 +2541,16 @@ decode_options (int argc, char **argv)
+ USAGE_ERROR ((0, 0, _("Cannot verify multi-volume archives")));
+ if (use_compress_program_option)
+ USAGE_ERROR ((0, 0, _("Cannot verify compressed archives")));
++ if (!IS_SUBCOMMAND_CLASS (SUBCL_WRITE))
++ USAGE_ERROR ((0, 0, _("--verify cannot be used with %s"),
++ subcommand_string (subcommand_option)));
+ }
+
+ if (use_compress_program_option)
+ {
+ if (multi_volume_option)
+ USAGE_ERROR ((0, 0, _("Cannot use multi-volume compressed archives")));
+- if (subcommand_option == UPDATE_SUBCOMMAND
+- || subcommand_option == APPEND_SUBCOMMAND
+- || subcommand_option == DELETE_SUBCOMMAND)
++ if (IS_SUBCOMMAND_CLASS (SUBCL_UPDATE))
+ USAGE_ERROR ((0, 0, _("Cannot update compressed archives")));
+ if (subcommand_option == CAT_SUBCOMMAND)
+ USAGE_ERROR ((0, 0, _("Cannot concatenate compressed archives")));
+@@ -2539,24 +2562,24 @@ decode_options (int argc, char **argv)
+ --gray */
+ if (args.pax_option
+ && archive_format != POSIX_FORMAT
+- && !READ_LIKE_SUBCOMMAND)
++ && !IS_SUBCOMMAND_CLASS (SUBCL_READ))
+ USAGE_ERROR ((0, 0, _("--pax-option can be used only on POSIX archives")));
+
+ /* star creates non-POSIX typed archives with xattr support, so allow the
+- extra headers whenn reading */
++ extra headers when reading */
+ if ((acls_option > 0)
+ && archive_format != POSIX_FORMAT
+- && !READ_LIKE_SUBCOMMAND)
++ && !IS_SUBCOMMAND_CLASS (SUBCL_READ))
+ USAGE_ERROR ((0, 0, _("--acls can be used only on POSIX archives")));
+
+ if ((selinux_context_option > 0)
+ && archive_format != POSIX_FORMAT
+- && !READ_LIKE_SUBCOMMAND)
++ && !IS_SUBCOMMAND_CLASS (SUBCL_READ))
+ USAGE_ERROR ((0, 0, _("--selinux can be used only on POSIX archives")));
+
+ if ((xattrs_option > 0)
+ && archive_format != POSIX_FORMAT
+- && !READ_LIKE_SUBCOMMAND)
++ && !IS_SUBCOMMAND_CLASS (SUBCL_READ))
+ USAGE_ERROR ((0, 0, _("--xattrs can be used only on POSIX archives")));
+
+ /* If ready to unlink hierarchies, so we are for simpler files. */
+diff --git a/tests/Makefile.am b/tests/Makefile.am
+index 6702063..a55b00e 100644
+--- a/tests/Makefile.am
++++ b/tests/Makefile.am
+@@ -128,6 +128,12 @@ TESTSUITE_AT = \
+ multiv07.at\
+ multiv08.at\
+ old.at\
++ opcomp01.at\
++ opcomp02.at\
++ opcomp03.at\
++ opcomp04.at\
++ opcomp05.at\
++ opcomp06.at\
+ options.at\
+ options02.at\
+ pipe.at\
+diff --git a/tests/opcomp01.at b/tests/opcomp01.at
+new file mode 100644
+index 0000000..f696be8
+--- /dev/null
++++ b/tests/opcomp01.at
+@@ -0,0 +1,34 @@
++# Process this file with autom4te to create testsuite. -*- Autotest -*-
++
++# Test suite for GNU tar.
++# Copyright 2013 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([occurrence compatibility])
++AT_KEYWORDS([opcomp opcomp01])
++
++AT_CHECK([
++tar --occurrence=1 -cf test.tar .
++],
++[2],
++[],
++[tar: --occurrence cannot be used with -c
++Try `tar --help' or `tar --usage' for more information.
++])
++
++AT_CLEANUP
++
+diff --git a/tests/opcomp02.at b/tests/opcomp02.at
+new file mode 100644
+index 0000000..85538c8
+--- /dev/null
++++ b/tests/opcomp02.at
+@@ -0,0 +1,34 @@
++# Process this file with autom4te to create testsuite. -*- Autotest -*-
++
++# Test suite for GNU tar.
++# Copyright 2013 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([occurrence compatibility])
++AT_KEYWORDS([opcomp opcomp02])
++
++AT_CHECK([
++tar --occurrence=1 -tf test.tar
++],
++[2],
++[],
++[tar: --occurrence is meaningless without a file list
++Try `tar --help' or `tar --usage' for more information.
++])
++
++AT_CLEANUP
++
+diff --git a/tests/opcomp03.at b/tests/opcomp03.at
+new file mode 100644
+index 0000000..aa54053
+--- /dev/null
++++ b/tests/opcomp03.at
+@@ -0,0 +1,34 @@
++# Process this file with autom4te to create testsuite. -*- Autotest -*-
++
++# Test suite for GNU tar.
++# Copyright 2013 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([--verify compatibility])
++AT_KEYWORDS([opcomp opcomp03])
++
++AT_CHECK([
++tar -tWf test.tar .
++],
++[2],
++[],
++[tar: --verify cannot be used with -t
++Try `tar --help' or `tar --usage' for more information.
++])
++
++AT_CLEANUP
++
+diff --git a/tests/opcomp04.at b/tests/opcomp04.at
+new file mode 100644
+index 0000000..67f94b5
+--- /dev/null
++++ b/tests/opcomp04.at
+@@ -0,0 +1,38 @@
++# Process this file with autom4te to create testsuite. -*- Autotest -*-
++
++# Test suite for GNU tar.
++# Copyright 2013 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([compress option compatibility])
++AT_KEYWORDS([opcomp opcomp04])
++
++AT_CHECK([
++AT_GZIP_PREREQ
++genfile --file file
++tar czf test.tar file
++genfile --file newfile
++tar rzf test.tar newfile
++],
++[2],
++[],
++[tar: Cannot update compressed archives
++Try `tar --help' or `tar --usage' for more information.
++])
++
++AT_CLEANUP
++
+diff --git a/tests/opcomp05.at b/tests/opcomp05.at
+new file mode 100644
+index 0000000..f470d4c
+--- /dev/null
++++ b/tests/opcomp05.at
+@@ -0,0 +1,34 @@
++# Process this file with autom4te to create testsuite. -*- Autotest -*-
++
++# Test suite for GNU tar.
++# Copyright 2013 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([--pax-option compatibility])
++AT_KEYWORDS([opcomp opcomp05])
++
++AT_CHECK([
++tar -Hgnu -cf test.tar --pax-option user:=root .
++],
++[2],
++[],
++[tar: --pax-option can be used only on POSIX archives
++Try `tar --help' or `tar --usage' for more information.
++])
++
++AT_CLEANUP
++
+diff --git a/tests/opcomp06.at b/tests/opcomp06.at
+new file mode 100644
+index 0000000..12de5b2
+--- /dev/null
++++ b/tests/opcomp06.at
+@@ -0,0 +1,36 @@
++# Process this file with autom4te to create testsuite. -*- Autotest -*-
++
++# Test suite for GNU tar.
++# Copyright 2013 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([--pax-option compatibility])
++AT_KEYWORDS([opcomp opcomp06])
++
++AT_CHECK([
++AT_ACLS_PREREQ
++genfile --file file
++tar -cf test.tar --acls -Hgnu file
++],
++[2],
++[],
++[tar: --acls can be used only on POSIX archives
++Try `tar --help' or `tar --usage' for more information.
++])
++
++AT_CLEANUP
++
+diff --git a/tests/testsuite.at b/tests/testsuite.at
+index 676bc2e..e17a6df 100644
+--- a/tests/testsuite.at
++++ b/tests/testsuite.at
+@@ -189,6 +189,13 @@ m4_include([pipe.at])
+ m4_include([options.at])
+ m4_include([options02.at])
+
++m4_include([opcomp01.at])
++m4_include([opcomp02.at])
++m4_include([opcomp03.at])
++m4_include([opcomp04.at])
++m4_include([opcomp05.at])
++m4_include([opcomp06.at])
++
+ m4_include([T-empty.at])
+ m4_include([T-null.at])
+
diff --git a/tar.spec b/tar.spec
index 4643dca..54f8b5a 100644
--- a/tar.spec
+++ b/tar.spec
@@ -160,6 +160,12 @@ Patch24: tar-1.26-sparse-inf-loops.patch
# ~> #916995
Patch25: tar-1.26-big-sparse-listing.patch
+# Don't segfault for --list mode and --verify
+# ~> upstream cfebb3cedf & 8a834dfa10
+# http://lists.gnu.org/archive/html/bug-tar/2013-06/msg00003.html
+# ~> #977807
+Patch26: tar-1.26-list-and-verify-segfault.patch
+
# Silence gcc warnings
# ~> upstream tar: 17f99bc6f, 5bb0433
# ~> upstream paxutils: 0b3d84a0
@@ -223,6 +229,7 @@ the rmt package on the remote box.
%patch23 -p1 -b .default-acls
%patch24 -p1 -b .inf-loops-in-sparse
%patch25 -p1 -b .big-sparse
+%patch26 -p1 -b .collision-of-options
%patch999 -p1 -b .silence-gcc
autoreconf -v
@@ -287,6 +294,7 @@ fi
- fix default ACLs propagation (#1082603)
- infinite loop(s) in sparse-file handling (#1082608)
- fix listing (and --verify) for big sparse files (#916995)
+- fix --list & --verify segfault (#986895)
* Thu Dec 12 2013 Pavel Raiskup <praiskup at redhat.com> - 1.26-30
- don't add git-hashes to patches
More information about the scm-commits
mailing list