This is an automated email from the ASF dual-hosted git repository. juergbi pushed a commit to branch jbilleter/tar in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit ec680c609cbf4497f8a11bc8d1e3d96568a0a1e8 Author: Jürg Billeter <[email protected]> AuthorDate: Fri Oct 30 17:47:13 2026 +0100 _tarfile.py: Apply fix from Python 3.11.18 Reject links replacing the destination in `tarfile.tar_filter`. https://github.com/python/cpython/pull/160343 --- src/buildstream/plugins/sources/_tarfile.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/buildstream/plugins/sources/_tarfile.py b/src/buildstream/plugins/sources/_tarfile.py index b3fccf43e..f52d1dfc2 100644 --- a/src/buildstream/plugins/sources/_tarfile.py +++ b/src/buildstream/plugins/sources/_tarfile.py @@ -798,6 +798,12 @@ def _get_filtered_attrs(member, dest_path, for_data=True): target_path = _realpath_allow_missing(os.path.join(dest_path, name)) if os.path.commonpath([target_path, dest_path]) != dest_path: raise OutsideDestinationError(member, target_path) + # A link member named after the destination directory itself + # would replace it with a (sym)link, redirecting the destination + # for all subsequent members. + if ((member.islnk() or member.issym()) + and os.path.normpath(name) == os.curdir): + raise OutsideDestinationError(member, target_path) # Limit permissions (no high bits, and go-w) mode = member.mode if mode is not None: @@ -833,11 +839,6 @@ def _get_filtered_attrs(member, dest_path, for_data=True): if member.islnk() or member.issym(): if os.path.isabs(member.linkname): raise AbsoluteLinkError(member) - # A link member that resolves to the destination directory itself - # would replace it with a (sym)link, redirecting the destination - # for all subsequent members. - if target_path == dest_path: - raise OutsideDestinationError(member, target_path) normalized = os.path.normpath(member.linkname) if normalized != member.linkname: new_attrs['linkname'] = normalized
