Skip to content

Tar fix 8 - #131074

Closed
alinpahontu2912 wants to merge 5 commits into
dotnet:release/8.0-stagingfrom
alinpahontu2912:tar_fix_8
Closed

Tar fix 8#131074
alinpahontu2912 wants to merge 5 commits into
dotnet:release/8.0-stagingfrom
alinpahontu2912:tar_fix_8

Conversation

@alinpahontu2912

Copy link
Copy Markdown
Member

No description provided.

alinpahontu2912 and others added 5 commits July 8, 2026 11:13
… symlink tests

When an entry resolves to the destination directory itself, the relative
path computation did an out-of-range Substring (logicalPrefix includes a
trailing separator). Return an empty relative path in that case. This also
fixes the ArgumentOutOfRangeException seen on macOS where the physical
destination path is longer than the logical one.

Remove the [ActiveIssue] dotnet#129227 tags now that the affected tests pass.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-system-formats-tar
See info in area-owners.md if you want to be subscribed.

Copilot AI left a comment

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.

Pull request overview

This PR updates System.Formats.Tar extraction path-safety logic to better handle symlink-resolution edge cases (notably on macOS where temp paths may traverse symlinked roots), and re-enables a set of Tar extraction tests that were previously disabled on macOS under an active issue.

Changes:

  • Fixes TarEntry.FilePathEscapesDirectory to compute relative components using a logical destination prefix (avoiding out-of-range Substring when the destination resolves to a longer physical path, e.g. /tmp → /private/tmp).
  • Adjusts symlink resolution in the traversal walk to treat non-links and dangling links more robustly (and removes several ActiveIssue(..., OSX) test suppressions).
  • Updates a Windows-only traversal test to accept either IOException or UnauthorizedAccessException, matching observed OS-build differences.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectoryAsync.Stream.Tests.cs Re-enables previously suppressed macOS tests by removing ActiveIssue annotations.
src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectoryAsync.File.Tests.cs Re-enables previously suppressed macOS tests by removing ActiveIssue annotations.
src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs Re-enables previously suppressed macOS tests by removing ActiveIssue annotations.
src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.File.Tests.cs Re-enables previously suppressed macOS/Windows tests by removing ActiveIssue annotations; expands Windows assertion for OS-dependent exception behavior.
src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarEntry.cs Fixes directory-escape detection to handle logical vs physical path prefixes safely and refines symlink resolution during traversal.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarEntry.cs
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.

2 participants