You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TarFile.getmember cannot work on tar sourced directory over 100 characters #91387
tarfile_repro.py: Example of tarfile bug using arm gcc compiler tarfile
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=Nonecreated_at=<Date2022-04-05.18:15:20.584>labels= ['type-bug', 'library', '3.9', '3.10', '3.11']
title='TarFile.getmember cannot work on tar sourced directory over 100 characters'updated_at=<Date2022-04-05.22:06:10.413>user='https://github.com/cfernald'
A fix was made to unify handling of the trailing slash in TarFile.getmember related to https://bugs.python.org/issue21987. This change fixed the <100 character case, but made it so directories over 100 character which come from a tar file can no longer be accessed through getmember, even if returned from getnames. This appears to be because internal to tarfile, member names still include the trailing slash on directories over 100 characters but getmember will always remove the trailing slash from the provided name so the comparison will always fail.
A simple example of this is as follows using 3.10.4.
Is there a logical reason to eagerly strip trailing slashes rather than only doing it for comparisons? (There might be, I just don't see it mentioned here, and I don't know the file format well enough to know if it's okay to lose that info.)
Activity
cfernald commentedon Apr 5, 2022
A fix was made to unify handling of the trailing slash in TarFile.getmember related to https://bugs.python.org/issue21987. This change fixed the <100 character case, but made it so directories over 100 character which come from a tar file can no longer be accessed through getmember, even if returned from getnames. This appears to be because internal to tarfile, member names still include the trailing slash on directories over 100 characters but getmember will always remove the trailing slash from the provided name so the comparison will always fail.
A simple example of this is as follows using 3.10.4.
Download: https://developer.arm.com/-/media/Files/downloads/gnu-a/10.3-2021.07/binrel/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu.tar.xz
place attached python script in same directory
run on 3.8.2 -> fails to get stripped version of path (line 16)
run on 3.10.4 -> fails to get even unstripped version (line 12 & 16)
ethanfurman commentedon Apr 5, 2022
Nosied others from bpo-21987.
cfernald commentedon Apr 11, 2022
Introduced Pull request 32423 to resolve this issue.
zooba commentedon Apr 27, 2022
Is there a logical reason to eagerly strip trailing slashes rather than only doing it for comparisons? (There might be, I just don't see it mentioned here, and I don't know the file format well enough to know if it's okay to lose that info.)
4 remaining items
pythongh-91387: Strip trailing slash from tarfile longname directories (
tiran commentedon Jun 18, 2022
The new test is causing issues on wasm32-wasi.
tiran commentedon Jun 18, 2022
The
rmdirsyscall on WASI does not like the trailing slash.pythongh-91387: Fix tarfile test on WASI
gh-91387: Fix tarfile test on WASI (GH-93984)
[3.11] pythongh-91387: Fix tarfile test on WASI (pythonGH-93984)
cfernald commentedon Jun 20, 2022
Thanks @ethanfurman ! sorry for the noise @tiran .
gh-91387: Strip trailing slash from tarfile longname directories (GH-…
gh-91387: Strip trailing slash from tarfile longname directories (GH-…
[3.11] pythongh-91387: Fix tarfile test on WASI (pythonGH-93984)
[3.11] gh-91387: Fix tarfile test on WASI (GH-93984) (#94074)
Revert 30935 defer bpo45162 to 312 (#94285)
hauntsaninja commentedon Oct 11, 2022
Thanks, looks like this has been completed