Skip to content

Reapply 7z next-header bounds validation to release - #1435

Merged
adamhathcock merged 6 commits into
releasefrom
rebuild/release-06-7z-header-bounds
Oct 9, 2026
Merged

adamhathcock merged 6 commits into
releasefrom
rebuild/release-06-7z-header-bounds

Conversation

@adamhathcock

Copy link
Copy Markdown
Owner

Summary

Reapplies #1430 to the clean release history after the accidental master merge was removed.

Validate next-header bounds before allocation in synchronous and asynchronous 7z parsing, with malformed-header and valid-boundary regression coverage.

Review and merge order

Recovery PR 5 of 5. Depends on #1434. Merge that PR first.

All recovery PRs target release. These branches are stacked, so this diff includes earlier recovery changes until the preceding PRs land. Review the replayed commit above for this PR's specific change. Merge in sequence using merge commits or fast-forward semantics to preserve shared ancestry; squash/rebase merging would require restacking the later branches.

The RAR comment test correction (e5c3ec6a) is already present in the clean base, so its checkpoint branch needs no separate PR. No master-only commits were replayed.

Validation

Validated the completed recovery stack on .NET 10:

  • Targeted regression suite: 247 tests passed.
  • Full test suite: 2,017 tests passed.
  • dotnet csharpier check . passed.
  • Working tree clean after formatting.

Validation was performed on the final stack, not separately on every intermediate branch.

Copilot AI balanced review requested due to automatic review settings October 9, 2026 13: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.

🟢 Approval recommended

The replayed validation is overflow-safe, consistent across sync and async paths, and has focused regression coverage.

0 open findings

What changed in this PR

Reapplies the 7z next-header bounds validation to the clean release stack. Merge after #1434.

Changes:

  • Validates synchronous and asynchronous 7z header ranges before allocation.
  • Adds malformed and exact-boundary regression coverage.
  • Includes earlier stacked ZIP, RAR, and GZip recovery fixes.
File Description
tests/​SharpCompress.Test/​Zip/​ZipArchiveTests.cs Tests uppercase ZIP multipart discovery.
tests/​SharpCompress.Test/​SevenZip/​SevenZipHeaderValidationTests.cs Covers truncated and boundary-valid 7z headers.
tests/​SharpCompress.Test/​Rar/​RarEncryptedHeaderScanTests.cs Covers repeated encrypted-header scans and solid extraction.
tests/​SharpCompress.Test/​GZip/​GZipExtraFieldTests.cs Covers unsigned XLEN values across APIs.
src/​SharpCompress/​Compressors/​Deflate/​ZlibBaseStream.cs Parses GZip XLEN as unsigned.
src/​SharpCompress/​Common/​SevenZip/​ArchiveReader.cs Adds synchronous next-header bounds checking.
src/​SharpCompress/​Common/​SevenZip/​ArchiveReader.Async.cs Adds asynchronous next-header bounds checking.
src/​SharpCompress/​Common/​Rar/​Headers/​RarHeaderFactory.cs Resets encryption state between scans.
src/​SharpCompress/​Common/​Rar/​Headers/​RarHeaderFactory.Async.cs Resets state for asynchronous scans.
src/​SharpCompress/​Common/​GZip/​GZipFilePart.cs Corrects synchronous XLEN parsing.
src/​SharpCompress/​Common/​GZip/​GZipFilePart.Async.cs Corrects asynchronous XLEN parsing.
src/​SharpCompress/​Archives/​Zip/​ZipArchiveVolumeFactory.cs Normalizes multipart ZIP extensions.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@adamhathcock
adamhathcock merged commit e4193af into release Oct 9, 2026
3 checks passed
@adamhathcock
adamhathcock deleted the rebuild/release-06-7z-header-bounds branch October 9, 2026 14:10
This was referenced Oct 9, 2026
This was referenced Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants