Skip to content

[release/11.0] Fix GNU sparse 1.0 maps spanning multiple TAR records - #136087

Open
github-actions[bot] wants to merge 2 commits into
release/11.0from
backport/pr-135626-to-release/11.0
Open

github-actions[bot] wants to merge 2 commits into
release/11.0from
backport/pr-135626-to-release/11.0

Conversation

@github-actions

@github-actions github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Backport of #135626 to release/11.0

/cc @rzikm

Customer Impact

  • Customer reported

.NET 11.0 added a feature for processing sparse TAR archives, however, a bug in the implementation prevents processing entries with lots of empty segments, requiring use of 3rd party or external tools as a workaround.

Regression

No, new feature in 11.0

Testing

Tests were added for CI verification

Risk

Low, the change is small and well understood.

<!-- -->

Valid GNU sparse 1.0 PAX entries can throw `InvalidDataException` when
their embedded sparse map exceeds approximately 1 KiB. The
refill-capacity check includes already-consumed bytes that the next
refill would discard during compaction.

Calculate capacity using only unread bytes. This preserves the fixed 1
KiB buffer, the 1,000,000-segment allocation limit, numeric-line bounds,
and record-aligned packed-data positioning.

Regression coverage checks exact record boundaries, the reported
1,006-byte and 1,062-byte map sizes, and an 8,193-byte map. It covers
sync/async reads and extraction, copied/non-copied data, non-seekable
inputs, next-entry alignment, and malformed maps.

### Validation

Commands ran through a short `subst` path on Windows x64:

- `.\build.cmd clr+libs -rc Release` - passed.
- `.\dotnet.cmd build
src\libraries\System.Formats.Tar\src\System.Formats.Tar.csproj` - passed
for the Windows and Unix target assemblies.
- `.\dotnet.cmd build /t:test
src\libraries\System.Formats.Tar\tests\System.Formats.Tar.Tests.csproj
'/p:XUnitOptions=-class
System.Formats.Tar.Tests.TarReader_SparseFileTests'` - 159 cases
executed; 32 valid-map cases failed before the fix, and all 159 passed
afterward.
- `.\dotnet.cmd build /t:test
src\libraries\System.Formats.Tar\tests\System.Formats.Tar.Tests.csproj`
- all 7,084 standard tests passed, with zero skips.

Both original issue archives passed sync/async reading and directory
extraction after the fix, with expanded lengths and SHA-256 hashes
matching Python `tarfile`. Non-Windows test execution and the
multi-gigabyte manual stress project were not run.

Fixes: #134980

Resolves #134980

> [!NOTE]
> This description was generated by GitHub Copilot.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 9b3e8fbb-f56a-48da-9df9-8c67a81584d0
@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.

Replace unavailable boolean-data helpers with explicit loops, preserving all 72 sparse-map test combinations.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: c955dea7-ec9e-43ec-8843-0c28e701ff58

This branch has not been deployed

No deployments
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.

1 participant