diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2017-05-29 11:31:12 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2017-05-29 11:31:12 +0300 |
commit | 795877532ec98536a9a3fe2395585561c4757a67 (patch) | |
tree | cd871d1804625076a9f682f8d7a85835d2960de8 /tests | |
parent | da8d0659a6fe8faf76b3a3275cf1f403e78edb1f (diff) | |
download | tar-795877532ec98536a9a3fe2395585561c4757a67.tar.gz |
Fix a bug in multi-volume archive creation.
When creating multivolume archives, the bufmap code in buffer.c
implicitly assumed that the members are stored in the archive
contiguously, ignoring the member (and eventual extended) headers
between them. This worked until the member header happened to be
at the very beginning of the volume, in which case its length was
included in the calculation of the stored size and size left to
store. Due to this, the GNUFileParts extended header contained
invalid GNU.volume.offset value, and the resulting archive failed
to extract properly.
This patch also eliminates improper listing of file part headers
as regular files, when creating multivolume posix archives with -v.
* src/buffer.c (bufmap): New member nblocks. Counts number of blocks
of file data written since reset.
(bufmap_reset): Reset nblocks to 0.
(_flush_write): Update nblocks. When computing offset difference for
bufmap_reset, count only data blocks, not headers.
(close_archive): Flush archive until all blocks are written.
(add_chunk_header): Use simple_finish_header instead of finish_header
to avoid listing chunk header as regular file in verbose mode.
* tests/multiv10.at: New test case.
* tests/Makefile.am: Add new test.
* tests/testsuite.at: Add new test.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 1 | ||||
-rw-r--r-- | tests/multiv10.at | 59 | ||||
-rw-r--r-- | tests/testsuite.at | 1 |
3 files changed, 61 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 92516fb3..70711676 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -155,6 +155,7 @@ TESTSUITE_AT = \ multiv07.at\ multiv08.at\ multiv09.at\ + multiv10.at\ numeric.at\ old.at\ onetop01.at\ diff --git a/tests/multiv10.at b/tests/multiv10.at new file mode 100644 index 00000000..03fbf15b --- /dev/null +++ b/tests/multiv10.at @@ -0,0 +1,59 @@ +# Process this file with autom4te to create testsuite. -*- Autotest -*- +# Test suite for GNU tar. +# Copyright 2015-2017 Free Software Foundation, Inc. +# +# 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/>. + +# Description: When creating multivolume archives, the bufmap code in +# buffer.c implicitly assumed that the members are stored in the archive +# in a contiguous fashion, ignoring the member (and eventual extended) headers +# between them. This worked until the member header happened to be at +# the very beginning of the volume, in which case its length was included in +# the calculation of the stored size and size left to store. Due to this, +# the GNUFileParts extended header contained invalid GNU.volume.offset value, +# and the resulting archive failed to extract properly. The bug affected +# versions of tar up to 1.29.90 (commit da8d0659a6). +# +# This test case also checks that GNUFileParts headers are not displayed in +# verbose mode. +# +# Reported by: <russiangolem@gmail.com> +# References: +# <CAE7Kiz_0oMqGdzkoh0FbOd=hUoPhtHHYhjZveM_4hEku081QFQ@mail.gmail.com>, +# http://lists.gnu.org/archive/html/bug-tar/2017-05/msg00007.html +# + +AT_SETUP([file start at the beginning of a posix volume]) +AT_KEYWORDS([multivolume multiv multiv10]) + +AT_TAR_CHECK([ +set -e +genfile --length=15360 --file data1 +genfile --length=15360 --file data2 +tar -v -c -L 10 -M -f 1.tar -f 2.tar -f 3.tar -f 4.tar -f 5.tar data1 data2 +tar -M -t -f 1.tar -f 2.tar -f 3.tar -f 4.tar -f 5.tar +mkdir out +tar -C out -M -x -f 1.tar -f 2.tar -f 3.tar -f 4.tar -f 5.tar +cmp data1 out/data1 +cmp data2 out/data2 +], +[0], +[data1 +data2 +data1 +data2 +], +[],[],[],[posix]) + +AT_CLEANUP diff --git a/tests/testsuite.at b/tests/testsuite.at index 483a7ea0..8c97e34c 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -377,6 +377,7 @@ m4_include([multiv06.at]) m4_include([multiv07.at]) m4_include([multiv08.at]) m4_include([multiv09.at]) +m4_include([multiv10.at]) AT_BANNER([Owner and Groups]) m4_include([owner.at]) |