Skip to content

Fix failing symlink tests#130342

Merged
alinpahontu2912 merged 4 commits into
dotnet:release/8.0-stagingfrom
alinpahontu2912:tar_fix_8
Jul 15, 2026
Merged

Fix failing symlink tests#130342
alinpahontu2912 merged 4 commits into
dotnet:release/8.0-stagingfrom
alinpahontu2912:tar_fix_8

Conversation

@alinpahontu2912

@alinpahontu2912 alinpahontu2912 commented Jul 8, 2026

Copy link
Copy Markdown
Member

Fixes #129227

Customer Impact

The new tar symlink resolution is not working properly on some platforms.

  • Customer reported
  • Found internally

Corrects a length mismatch that made the Tar traversal guard crash with  ArgumentOutOfRangeException  (subtracting a symlink-resolved path length from a logical path). Without it, extraction to any symlinked destination (macOS  /var ,  /tmp ) is broken.

Regression

  • Yes
  • No

Testing

Reenabled failing CI tests.

Risk

Low.

@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 re-enables previously skipped symlink-related TarFile.ExtractToDirectory tests and updates tar extraction path validation to better detect directory traversal via symlinks created by earlier archive entries.

Changes:

  • Removed ActiveIssue skips for symlink traversal tests so they run again on macOS (and Windows for the chained traversal test).
  • Updated TarEntry.FilePathEscapesDirectory to compute a logical relative path first and to resolve symlinks during component-by-component traversal (including dangling links).

Reviewed changes

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

File Description
src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.File.Tests.cs Re-enables symlink traversal tests by removing ActiveIssue skips.
src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarEntry.cs Adjusts path-escape detection logic to better account for symlink resolution during extraction.

💡 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 Outdated
svick
svick previously requested changes Jul 8, 2026
… 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>
Copilot AI review requested due to automatic review settings July 9, 2026 07:50

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

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

Comment thread src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarEntry.cs Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 9, 2026 07:55

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

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

Comment thread src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarEntry.cs
@mrek-msft

Copy link
Copy Markdown
Member

Hi,

the code complete date for 8.0.30 (the August 2026 release) is Monday 2026-07-13. Make sure to merge this PR on that date at the latest, or it won't make it into that release.

As a reminder, to merge it, you need Tactics approval, the PR needs to be approved by another area co-owner and there can't be any CI failures that could be related to the fix.

@svick
svick dismissed their stale review July 10, 2026 10:58

All relevant ActiveIssue attributes have been removed.

@alinpahontu2912
alinpahontu2912 enabled auto-merge (squash) July 15, 2026 08:16
Copilot AI review requested due to automatic review settings July 15, 2026 08:30

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

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Comment thread src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarEntry.cs
Comment thread src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarEntry.cs
@alinpahontu2912

Copy link
Copy Markdown
Member Author

Got email approval for merging

@alinpahontu2912

Copy link
Copy Markdown
Member Author

/ba-g test failures not related to my fix

@alinpahontu2912
alinpahontu2912 merged commit 659c41d into dotnet:release/8.0-staging Jul 15, 2026
112 of 119 checks passed
alinpahontu2912 added a commit that referenced this pull request Jul 15, 2026
Backport of #130342 to .NET 9.

Fixes #129227

## Customer Impact
The new tar symlink resolution is not working properly on some
platforms.

- [ ] Customer reported
- [x] Found internally

Corrects a length mismatch that made the Tar traversal guard crash with
 ArgumentOutOfRangeException  (subtracting a symlink-resolved path
length from a logical path). Without it, extraction to any symlinked
destination (macOS  /var ,  /tmp ) is broken.

## Regression

- [x] Yes
- [ ] No

## Testing

Reenabled failing CI tests.

## Risk

Low.

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
svick pushed a commit that referenced this pull request Jul 22, 2026
Backport of #130342 to release/10.0.

Fixes #129227

## Customer Impact
The new tar symlink resolution is not working properly on some
platforms.

- [ ] Customer reported
- [x] Found internally

Corrects a length mismatch that made the Tar traversal guard crash with
 ArgumentOutOfRangeException  (subtracting a symlink-resolved path
length from a logical path). Without it, extraction to any symlinked
destination (macOS  /var ,  /tmp ) is broken.

## Regression

- [x] Yes
- [ ] No

## Testing

Reenabled failing CI tests.

## Risk

Low.

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-System.Formats.Tar Servicing-approved Approved for servicing release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants