Fix failing symlink tests#130342
Conversation
|
Tagging subscribers to this area: @dotnet/area-system-formats-tar |
There was a problem hiding this comment.
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
ActiveIssueskips for symlink traversal tests so they run again on macOS (and Windows for the chained traversal test). - Updated
TarEntry.FilePathEscapesDirectoryto 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.
… 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>
|
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. |
All relevant ActiveIssue attributes have been removed.
|
Got email approval for merging |
|
/ba-g test failures not related to my fix |
659c41d
into
dotnet:release/8.0-staging
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>
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>
Fixes #129227
Customer Impact
The new tar symlink resolution is not working properly on some platforms.
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
Testing
Reenabled failing CI tests.
Risk
Low.