This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author faik
Recipients
Date 2006-06-21.11:44:38
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
tarfile.py in python 2.4.3 version has a bug that makes 
it to stop iteration while reading members. 

If a file's name is longer than 100 bytes, after 
reading ././@LongLink header of the file in the tar 
archive, tarfile tries to read the actual header. But if the 
100 byte of the file's name ends with "/" and it is a 
regular file (type is a file type). Tarfile changes it's type 
to a directory by thinking that it is some old tar archive 
format's directory member (because it seems to end 
with a "/").

I created a tar archive to test this case. You can find it 
in the attachments.

My test code does this:

#!/usr/bin/python
import tarfile
import sys
tar = tarfile.open(sys.argv[1], "r")
tar.list()

If I run it with the prepared tar file, i get this output:

faik@pardus tmp $ ./tarlist.py longfiles.tar
-rwxr-xr-x faik/users          0 2006-06-21 13:03:59 
this.is.a.very.long.directory.name/
-rwxr-xr-x faik/users          0 2006-06-21 13:06:17 
this.is.a.very.long.directory.name/this.is.another.very.long.directory.name/
-rwxr-xr-x faik/users          0 2006-06-21 13:08:21 
this.is.a.very.long.directory.name/this.is.another.very.long.directory.name/and.this.is.another.one/
-rw-r--r-- faik/users         19 2006-06-21 13:08:41 
this.is.a.very.long.directory.name/this.is.another.very.long.directory.name/and.this.is.another.one/NEWS

But if I run tar(1) with tvf options, i get this output:

faik@pardus tmp $ tar tvf longfiles.tar
drwxr-xr-x faik/users        0 2006-06-21 13:03:59 
this.is.a.very.long.directory.name/
drwxr-xr-x faik/users        0 2006-06-21 13:06:17 
this.is.a.very.long.directory.name/this.is.another.very.long.directory.name/
drwxr-xr-x faik/users        0 2006-06-21 13:08:21 
this.is.a.very.long.directory.name/this.is.another.very.long.directory.name/and.this.is.another.one/
-rw-r--r-- faik/users       19 2006-06-21 13:08:41 
this.is.a.very.long.directory.name/this.is.another.very.long.directory.name/and.this.is.another.one/NEWS
-rw-r--r-- faik/users       18 2006-06-21 13:10:10 
this.is.a.very.long.directory.name/this.is.another.very.long.directory.name/and.this.is.another.one/COPYING
-rw-r--r-- faik/users       26 2006-06-21 13:09:05 
this.is.a.very.long.directory.name/this.is.another.very.long.directory.name/and.this.is.another.one/README

tarfile.py ends iteration with this member 
file: "this.is.a.very.long.directory.name/this.is.another.very.long.directory.name/and.this.is.another.one/NEWS".
Because the full directory path name length that 
contains the NEWS file is exactly 100 bytes long.

There is also an attachment for the fix of the bug. 
History
Date User Action Args
2007-08-23 15:53:04adminlinkissue1509889 messages
2007-08-23 15:53:04admincreate