> On Mar 12, 2016, at 8:44 AM, Sergey Poznyakoff <[email protected]> wrote: > > Hi Renate, > >> Here is a test case that clearly fails: > > The test fails because it invokes truncate, which cripples the archive.
No, that's just how Renate was able to create an archive that demonstrates the bug. If you look at a hex dump, you'll see that the truncated result is a valid archive with two blocks of zeros as a valid end-of-archive marker. > With that part commented out, it runs as expected and produces a correct > archive. Tested with 1.28 and git HEAD. You can also reproduce the bug by playing with the -b option. #!/bin/sh # This demonstrates a bug in GNU tar's handling of -r. gnutar --version for f in a b c d e f g h i; do echo $f>$f done echo echo 'Creating archive with a, b, c' gnutar -v -cf data -b1 a b c gnutar -v -tf data echo echo 'Adding d, e, f' gnutar -v -rf data -b3 d e f gnutar -v -tf data echo echo 'Adding g, h, i' gnutar -v -rf data -b5 g h i gnutar -v -tf data ######### end of script ######################### Here's the output of the above on an OS X machine using a recent gnutar from MacPorts: tar (GNU tar) 1.28 Copyright (C) 2014 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Written by John Gilmore and Jay Fenlason. Creating archive with a, b, c a b c -rw-r--r-- tim/staff 2 2016-03-12 12:35 a -rw-r--r-- tim/staff 2 2016-03-12 12:35 b -rw-r--r-- tim/staff 2 2016-03-12 12:35 c Adding d, e, f d e f -rw-r--r-- tim/staff 2 2016-03-12 12:35 a -rw-r--r-- tim/staff 2 2016-03-12 12:35 b -rw-r--r-- tim/staff 2 2016-03-12 12:35 c gnutar: Skipping to next header -rw-r--r-- tim/staff 2 2016-03-12 12:35 e -rw-r--r-- tim/staff 2 2016-03-12 12:35 f gnutar: Exiting with failure status due to previous errors Adding g, h, i gnutar: Skipping to next header g h i gnutar: Exiting with failure status due to previous errors -rw-r--r-- tim/staff 2 2016-03-12 12:35 a -rw-r--r-- tim/staff 2 2016-03-12 12:35 b -rw-r--r-- tim/staff 2 2016-03-12 12:35 c gnutar: Skipping to next header -rw-r--r-- tim/staff 2 2016-03-12 12:35 e gnutar: Skipping to next header -rw-r--r-- tim/staff 2 2016-03-12 12:35 g gnutar: Skipping to next header -rw-r--r-- tim/staff 2 2016-03-12 12:35 h -rw-r--r-- tim/staff 2 2016-03-12 12:35 i gnutar: Exiting with failure status due to previous errors
