[issue14160] TarFile.extractfile fails to extract targets of top-level relative symlinks
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset 0adf4fd8df83 by Lars Gustäbel in branch '3.2': Issue #14160: TarFile.extractfile() failed to resolve symbolic links http://hg.python.org/cpython/rev/0adf4fd8df83 New changeset 38df99776901 by Lars Gustäbel in branch 'default': Merge with 3.2: Issue #14160: TarFile.extractfile() failed to resolve symbolic http://hg.python.org/cpython/rev/38df99776901 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14160 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14160] TarFile.extractfile fails to extract targets of top-level relative symlinks
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset aff14bea5596 by Lars Gustäbel in branch '2.7': Issue #14160: TarFile.extractfile() failed to resolve symbolic links when http://hg.python.org/cpython/rev/aff14bea5596 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14160 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14160] TarFile.extractfile fails to extract targets of top-level relative symlinks
Lars Gustäbel l...@gustaebel.de added the comment: Fixed. Thanks for the report. -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14160 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14160] TarFile.extractfile fails to extract targets of top-level relative symlinks
Changes by Lars Gustäbel l...@gustaebel.de: -- assignee: - lars.gustaebel ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14160 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14160] TarFile.extractfile fails to extract targets of top-level relative symlinks
Lars Gustäbel l...@gustaebel.de added the comment: Thanks for the report. Attached is a patch (against 3.2) that is supposed to fix the problem. -- keywords: +patch stage: - patch review Added file: http://bugs.python.org/file24735/issue14160.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14160 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14160] TarFile.extractfile fails to extract targets of top-level relative symlinks
Changes by Matthew Miller mat...@mattdm.org: -- type: - behavior ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14160 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14160] Tarfile.extractfile fails to extract targets of top-level relative symlinks
New submission from Matthew Miller mat...@mattdm.org: I have a tarfile with relative paths. The tail of tar tvf looks like this: -rw-r--r-T nobody/nobody 1356 2012-02-28 19:25 s/772 -rw-r--r-- nobody/nobody 1304 2012-02-28 19:25 s/773 -rw-r--r-- nobody/nobody 1304 2012-02-28 19:25 s/774 -rw-r--r-- nobody/nobody 1304 2012-02-28 19:25 s/775 lrw-r--r-- nobody/nobody 0 2012-02-28 19:25 final - s/772 The docs say: TarFile.extractfile(member) Extract a member from the archive as a file object. member may be a filename or a TarInfo object. If member is a regular file, a file-like object is returned. If member is a link, a file-like object is constructed from the link’s target. However, what I'm getting is this: KeyError: linkname '/s/772' not found It's appending a /. Why? Well, in tarfile.py: if tarinfo.issym(): # Always search the entire archive. linkname = os.path.dirname(tarinfo.name) + / + tarinfo.linkname limit = None Here, os.path.dirname(tarinfo.name) returns '', and then the / is appended, giving an incorrect result. One solution would be: linkname = os.path.join(os.path.dirname(tarinfo.name),tarinfo.linkname) but I don't think that works on platforms where os.sep is not /, since tar will want / in any case. But that's the correct logic. I'm filing this against 2.7, but the same issue exists in 3.2. A work-around in end-user code is to call Tarfile.getmember(filename), check if the result issym(), and replace the result with Tarfile.getmember(tarinfo.linkname). But since the extractfile function is documented as following symlinks, that should not be necessary. This bug isn't commonly encountered because by convention tarfiles usually contain a subdirectory and everything goes in that. But we should do the right thing. -- components: Library (Lib) messages: 154643 nosy: Matthew.Miller priority: normal severity: normal status: open title: Tarfile.extractfile fails to extract targets of top-level relative symlinks versions: Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14160 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14160] TarFile.extractfile fails to extract targets of top-level relative symlinks
Changes by Éric Araujo mer...@netwok.org: -- nosy: +eric.araujo, lars.gustaebel title: Tarfile.extractfile fails to extract targets of top-level relative symlinks - TarFile.extractfile fails to extract targets of top-level relative symlinks versions: +Python 3.2, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14160 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com