[issue29612] TarFile.extract() suffers from hard links inside tarball
Larry Cook
report at bugs.python.org
Fri Feb 16 10:04:18 EST 2018
Larry Cook <lcook at hytrust.com> added the comment:
I recently hit this with Python 2.7.5 and 2.7.13. It has a very simple repro. Just specify the same file twice on the command line to tar (GNU 1.26):
% tar cvf test.tar test.txt test.txt
test.txt
test.txt
% tar tvf test.tar
-rw-r--r-- root/root 24 2018-02-16 09:35 test.txt
hrw-r--r-- root/root 0 2018-02-16 09:35 test.txt link to test.txt
% python2.7
Python 2.7.5 (default, Aug 4 2017, 00:39:18)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tarfile
>>> tarball = tarfile.open("test.tar")
>>> tarball.extractall()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python2.7/tarfile.py", line 2047, in extractall
self.extract(tarinfo, path)
File "/usr/lib64/python2.7/tarfile.py", line 2084, in extract
self._extract_member(tarinfo, os.path.join(path, tarinfo.name))
File "/usr/lib64/python2.7/tarfile.py", line 2168, in _extract_member
self.makelink(tarinfo, targetpath)
File "/usr/lib64/python2.7/tarfile.py", line 2252, in makelink
os.link(tarinfo._link_target, targetpath)
OSError: [Errno 2] No such file or directory
>>>
----------
nosy: +Larry Cook
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue29612>
_______________________________________
More information about the Python-bugs-list
mailing list