[issue23228] The tarfile module crashes when tarfile contains a symlink and unpack directory contain it too

Martin Panter report at bugs.python.org
Sat Dec 15 20:34:29 EST 2018


Martin Panter <vadmium+py at gmail.com> added the comment:

The problem with WindowsError should only exist in 3.4+. 2.7 doesn’t support creating symlinks on Windows.

Michael’s fix is the same as already done in 2.7 for Issue 10761 and (part of) Issue 12088. However I’m not sure that is the best approach for a bug fix. Also see Issue 19974 proposing to replace existing directory entries in all cases, including replacing empty subdirectories, and not just when extracting symlinks.

I suspect Michael has only fixed the recursive loop on Unix. What happens if an exception is raised because symlinks are not supported (e.g. Windows)? Possible test case:

data = BytesIO()
writer = tarfile.TarFile(fileobj=data, mode='w')
selflink = tarfile.TarInfo('self')
selflink.size = 0
selflink.type = tarfile.SYMTYPE
selflink.linkname = selflink.name
writer.addfile(selflink)
writer.close()
data.seek(0)
tarfile.TarFile(fileobj=data).extractall()

----------
nosy: +martin.panter

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue23228>
_______________________________________


More information about the Python-bugs-list mailing list