Skip to content

gh-157190: Follow symlinks when extracting tarfile hard links - #157191

Open
StanFromIreland wants to merge 4 commits into
python:mainfrom
StanFromIreland:sneaky_hardlink_relocation
Open

gh-157190: Follow symlinks when extracting tarfile hard links#157191
StanFromIreland wants to merge 4 commits into
python:mainfrom
StanFromIreland:sneaky_hardlink_relocation

Conversation

@StanFromIreland

@StanFromIreland StanFromIreland commented Sep 8, 2026

Copy link
Copy Markdown
Member

@StanFromIreland StanFromIreland added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Sep 8, 2026
@bedevere-bot

Copy link
Copy Markdown

🤖 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.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Sep 8, 2026

@encukou encukou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread Lib/tarfile.py Outdated
Comment thread Lib/test/test_tarfile.py

@symlink_test
@os_helper.skip_unless_hardlink
def test_sneaky_hardlink_relocation(self):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to test also a symlink pointing to a directory?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what that would be testing, a hard link to a directory isn't possible.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/s

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants