[PR #722] [MERGED] Zip Multipart fix, XZ stream fix, XZ stream support added to zip/zipx #1180

Closed
opened 2026-01-29 22:19:22 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/adamhathcock/sharpcompress/pull/722
Author: @Nanook
Created: 2/2/2023
Status: Merged
Merged: 3/1/2023
Merged by: @adamhathcock

Base: masterHead: fixes-XZ-zip


📝 Commits (2)

  • 48a341b Split archive handling fix. XZ stream decoding bug fix (in X64Convert filter). XZ stream support added to zip/zipx.
  • b9d0195 Added the XZ zipx unit test.

📊 Changes

7 files changed (+92 additions, -64 deletions)

View changed files

📝 src/SharpCompress/Common/Zip/ZipCompressionMethod.cs (+1 -0)
📝 src/SharpCompress/Common/Zip/ZipFilePart.cs (+5 -0)
📝 src/SharpCompress/Compressors/Filters/BranchExecFilter.cs (+75 -61)
📝 src/SharpCompress/IO/ReadOnlySubStream.cs (+6 -2)
📝 src/SharpCompress/IO/SourceStream.cs (+1 -0)
📝 tests/SharpCompress.Test/Zip/ZipArchiveTests.cs (+4 -1)
tests/TestArchives/Archives/WinZip27_XZ.zipx (+0 -0)

📄 Description

Split archives using SourceStream.cs were not moving on to the next part when a call Read() spanned 2 parts.

XZ stream support added to zip and zipx. (Which are created by WinZip)

The XZ decoder had a bug that was corrupting data sometimes without error. This was noticed when adding the unit test for WinZip27.XZ.zipx. The previous code fails with this zip (2 bytes in the middle of the exe are invalid). The fix was to re-port X86Converter() in BranchExecFilter.cs. I used a version from https://github.com/torvalds/linux/blob/master/lib/xz/xz_dec_bcj.c

I will also submit a PR that adds Zstandard to zip/zipx and 7zip. Currently this uses a 3rd party nuget package, I don't expect it to be merged, but it might serve as a reference.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/adamhathcock/sharpcompress/pull/722 **Author:** [@Nanook](https://github.com/Nanook) **Created:** 2/2/2023 **Status:** ✅ Merged **Merged:** 3/1/2023 **Merged by:** [@adamhathcock](https://github.com/adamhathcock) **Base:** `master` ← **Head:** `fixes-XZ-zip` --- ### 📝 Commits (2) - [`48a341b`](https://github.com/adamhathcock/sharpcompress/commit/48a341b79c8989493546ca7cb601f0d1d64ded0a) Split archive handling fix. XZ stream decoding bug fix (in X64Convert filter). XZ stream support added to zip/zipx. - [`b9d0195`](https://github.com/adamhathcock/sharpcompress/commit/b9d019561f8be6c7195bfeab482824284617f351) Added the XZ zipx unit test. ### 📊 Changes **7 files changed** (+92 additions, -64 deletions) <details> <summary>View changed files</summary> 📝 `src/SharpCompress/Common/Zip/ZipCompressionMethod.cs` (+1 -0) 📝 `src/SharpCompress/Common/Zip/ZipFilePart.cs` (+5 -0) 📝 `src/SharpCompress/Compressors/Filters/BranchExecFilter.cs` (+75 -61) 📝 `src/SharpCompress/IO/ReadOnlySubStream.cs` (+6 -2) 📝 `src/SharpCompress/IO/SourceStream.cs` (+1 -0) 📝 `tests/SharpCompress.Test/Zip/ZipArchiveTests.cs` (+4 -1) ➕ `tests/TestArchives/Archives/WinZip27_XZ.zipx` (+0 -0) </details> ### 📄 Description Split archives using SourceStream.cs were not moving on to the next part when a call Read() spanned 2 parts. XZ stream support added to zip and zipx. (Which are created by WinZip) The XZ decoder had a bug that was corrupting data sometimes without error. This was noticed when adding the unit test for WinZip27.XZ.zipx. The previous code fails with this zip (2 bytes in the middle of the exe are invalid). The fix was to re-port X86Converter() in BranchExecFilter.cs. I used a version from https://github.com/torvalds/linux/blob/master/lib/xz/xz_dec_bcj.c I will also submit a PR that adds Zstandard to zip/zipx and 7zip. Currently this uses a 3rd party nuget package, I don't expect it to be merged, but it might serve as a reference. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 22:19:22 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#1180