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.

classification
Title: tarfile.py chokes on long names
Type: Stage:
Components: Library (Lib) Versions: Python 2.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: alexanderweb, georg.brandl, lars.gustaebel
Priority: normal Keywords:

Created on 2006-04-16 20:34 by alexanderweb, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (6)
msg28252 - (view) Author: Alexander Schremmer (alexanderweb) Date: 2006-04-16 20:34
The following bug is reproducible on Py 2.4.3 and 2.5. 
It was tested on Windows. You need a tarfile with a 
long file name that triggers the GNU LONGNAME 
extension.

Extracting such a file gives me an IO error because it 
tries to create a file with a slash at the end. This is 
because 

        # Some old tar programs represent a directory 
as a regular
        # file with a trailing slash.
        if tarinfo.isreg() and tarinfo.name.endswith("/
"):
            tarinfo.type = DIRTYPE

sets the type incorrectly after it was called from the 
callback proc which has no possiblity to set the name 
of the intermediary tarinfo class because it is 
instantiated in the next-method.

So this yields a directory which should be a file which 
is obviously wrong. Might be related to commit 41340 
"Patch #1338314, Bug #1336623". (At least the code 
changed there is causing this bug).
msg28253 - (view) Author: Alexander Schremmer (alexanderweb) Date: 2006-04-16 20:34
Logged In: YES 
user_id=254738

Hmm, I just want to clarify that tarfile doesn't give the IO 
error (it passes silently) but my code that expects a file 
instead of a directory ;-)
msg28254 - (view) Author: Lars Gustäbel (lars.gustaebel) * (Python committer) Date: 2006-04-25 20:59
Logged In: YES 
user_id=642936

Fixing this issue is not quite as simple as I hoped it to
be. It would be possible to implement a quick fix that
solves the problem, but that would be too ugly for a stdlib
module. Instead, I have been busy writing a preliminary fix
for my development version of tarfile.py which is available
at http://www.gustaebel.de/lars/tarfile/.
It would be nice of you, if you'd download the 0.8.0 version
there and give it a try. Thank you.
msg28255 - (view) Author: Alexander Schremmer (alexanderweb) Date: 2006-05-07 11:55
Logged In: YES 
user_id=254738

Thanks, that seems to work. Try to get this into Py 2.5 :)
msg28256 - (view) Author: Lars Gustäbel (lars.gustaebel) * (Python committer) Date: 2006-05-09 13:56
Logged In: YES 
user_id=642936

I have posted the fix as patch #1484695. Thanks for your report.
msg28257 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-05-10 16:26
Logged In: YES 
user_id=849994

Said patch has now been applied.
History
Date User Action Args
2022-04-11 14:56:16adminsetgithub: 43225
2006-04-16 20:34:03alexanderwebcreate