[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-tar] bug in GNU tar? -- backslashes break the --files-from= option
From: |
Doug McLaren |
Subject: |
[Bug-tar] bug in GNU tar? -- backslashes break the --files-from= option |
Date: |
Wed, 17 Aug 2005 16:10:13 -0500 |
User-agent: |
Mutt/1.4.1i |
I think I've found a bug in GNU tar. It's somewhat serious (as it can
cause files to not be archived), though it's rather obscure -- only
people who have files with backslashes in them, and who are using the
--files-from= (or -T) option will see it. And then only sometimes.
It's related to the --files-from= option and backslashes. Apparantly
tar is parsing the backslashes found in the filenames, perhaps trying
to convert sequences that could represent control characters into
those control characters? Like \4 is converted to a control-D, or \f
into a form feed? At least that's how it seems to be working -- I
haven't verified it.
(But the fact that when fed `file\4' (with no zeros) the error reads
--
tar: file\004: Cannot stat: No such file or directory
strongly suggests it.)
Traditionally, when you have null terminated strings like this,
there's no interpetation of the input data at all, but GNU tar seems
to be doing so. GNU xargs has a --null option as well and does not
seem to have the same problem. (Of course, xargs accepts the input
from STDIN by default, where in tar you have to enable that
specifically with --files-from=-.)
Also, it's not specific to the --null argument -- if I remove the
--null option (but leave --files-from=-) and send it file names ending
in ^J, it will fail in the same way.
I've included a perl script that demonstrates the problem for you.
It's just a quick testcase -- not meant to be pretty :)
I found the problem on a Linux box running Fedora Core 4 using their
version of tar -- 1.15.1. I also downloaded 1.15.1 from
http://www.gnu.org/software/tar/tar.html and built it again to make
sure it wasn't due to some FC4 specific changes. It wasn't.
I also tried it on FreeBSD (against tar 1.13.25) -- same problem. I
don't think it's OS specific.
Replacing \'s in the input to tar with \\'s seems to get around the
problem, though you shouldn't have to do that, especially with --null.
I would expect --null and --files-from=- together to accept files from
STDIN and do no interpetation on the file names at all.
Here's the output of my script --
% ~/tar-testcase
Version of tar that we're testing :
tar (GNU tar) 1.15.1
Test directory = tar-testcase-dir
Creating file1 file2 fil\e3 file\4 \file5 file6\ file7 fil\e8 file\9 ...
total 48
drwxr-xr-x 2 dmclaren wheel 4096 Aug 17 14:56 .
drwxr-xr-x 90 dmclaren root 8192 Aug 17 14:56 ..
-rw-r--r-- 1 dmclaren wheel 16 Aug 17 14:56 \file5
-rw-r--r-- 1 dmclaren wheel 16 Aug 17 14:56 fil\e3
-rw-r--r-- 1 dmclaren wheel 16 Aug 17 14:56 fil\e8
-rw-r--r-- 1 dmclaren wheel 15 Aug 17 14:56 file1
-rw-r--r-- 1 dmclaren wheel 15 Aug 17 14:56 file2
-rw-r--r-- 1 dmclaren wheel 16 Aug 17 14:56 file6\
-rw-r--r-- 1 dmclaren wheel 15 Aug 17 14:56 file7
-rw-r--r-- 1 dmclaren wheel 16 Aug 17 14:56 file\4
-rw-r--r-- 1 dmclaren wheel 16 Aug 17 14:56 file\9
Invoking tar to tar them up :
...feeding filename file1 to tar.
...feeding filename file2 to tar.
...feeding filename fil\e3 to tar.
...feeding filename file\4 to tar.
...feeding filename \file5 to tar.
...feeding filename file6\ to tar.
...feeding filename file7 to tar.
...feeding filename fil\e8 to tar.
...feeding filename file\9 to tar.
-rw-r--r-- dmclaren/wheel 15 2005-08-17 14:56:17 file1
-rw-r--r-- dmclaren/wheel 15 2005-08-17 14:56:17 file2
-rw-r--r-- dmclaren/wheel 16 2005-08-17 14:56:17 fil\\e3
tar: file\004: Cannot stat: No such file or directory
tar: \file5: Cannot stat: No such file or directory
-rw-r--r-- dmclaren/wheel 16 2005-08-17 14:56:17 file6\\
-rw-r--r-- dmclaren/wheel 15 2005-08-17 14:56:17 file7
-rw-r--r-- dmclaren/wheel 16 2005-08-17 14:56:17 fil\\e8
-rw-r--r-- dmclaren/wheel 16 2005-08-17 14:56:17 file\\9
tar: Error exit delayed from previous errors
Did tar report any errors? It should not have.
Listing the tar file created :
-rw-r--r-- dmclaren/wheel 15 2005-08-17 14:56:17 file1
-rw-r--r-- dmclaren/wheel 15 2005-08-17 14:56:17 file2
-rw-r--r-- dmclaren/wheel 16 2005-08-17 14:56:17 fil\\e3
-rw-r--r-- dmclaren/wheel 16 2005-08-17 14:56:17 file6\\
-rw-r--r-- dmclaren/wheel 15 2005-08-17 14:56:17 file7
-rw-r--r-- dmclaren/wheel 16 2005-08-17 14:56:17 fil\\e8
-rw-r--r-- dmclaren/wheel 16 2005-08-17 14:56:17 file\\9
.tar-input-file should contain the same files that were fed to tar.
You can run this test without perl by doing this :
cd tar-testcase-dir
cat .tar-input-file | tar -cvvvf test.tar --files-from=- --null
tar -tvvvf test.tar
cd ..
--
Doug McLaren, address@hidden
That which does not kill us, is defective and should be sent back for repairs.
tar-testcase
Description: Text document
- [Bug-tar] bug in GNU tar? -- backslashes break the --files-from= option,
Doug McLaren <=