gh-157190: Follow symlinks when extracting tarfile hard links - #157191
Conversation
|
🤖 New build scheduled with the buildbot fleet by @StanFromIreland for commit 027cfba 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F157191%2Fmerge If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again. |
encukou
left a comment
There was a problem hiding this comment.
LGTM; let's merge if the buildbots or the 3.13 backport don't fail in tarfile.
When merging: the commit message should mention that the fixed bug only exists in 3.13 and below.
|
|
||
| @symlink_test | ||
| @os_helper.skip_unless_hardlink | ||
| def test_sneaky_hardlink_relocation(self): |
There was a problem hiding this comment.
Do we want to test also a symlink pointing to a directory?
There was a problem hiding this comment.
I'm not sure what that would be testing, a hard link to a directory isn't possible.
There was a problem hiding this comment.
I meant a hard link to the symlink, where the symlink points to a directory.
Something like that:
2026-09-09T17:26:21.505759000+0200 maurycy@gimel /tmp/tarararara % tar tvf evil.tar
drw-r--r-- 0 0 0 0 Jan 1 1970 a/d/
-rw-r--r-- 0 0 0 5 Jan 1 1970 a/d/f
lrw-r--r-- 0 0 0 0 Jan 1 1970 a/b/s -> ../d
hrw-r--r-- 0 0 0 0 Jan 1 1970 s link to a/b/sThere was a problem hiding this comment.
os.link() raises on a directory, so it falls through to the fallback branch, which is the path test_sneaky_hardlink_fallback_deep covers.
Co-authored-by: Maurycy Pawłowski-Wieroński <maurycy@maurycy.com>
|
Thanks @StanFromIreland for the PR, and @encukou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14. |
|
Thanks @StanFromIreland for the PR, and @encukou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15. |
|
GH-157261 is a backport of this pull request to the 3.14 branch. |
|
GH-157262 is a backport of this pull request to the 3.15 branch. |
|
data/tarfilter bypass via hard link to a symlink #157190