mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-04 05:25:00 +00:00
[PR #939] [MERGED] Fix WinzipAesCryptoStream potentially not getting disposed #1358
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/adamhathcock/sharpcompress/pull/939
Author: @Morilli
Created: 8/21/2025
Status: ✅ Merged
Merged: 8/22/2025
Merged by: @adamhathcock
Base:
master← Head:fix-winaescryptostream-dispose📝 Commits (2)
8eea2ceadd failing test9f30696Adjust logic in CreateDecompressionStream to not wrap the returned stream📊 Changes
3 files changed (+20 additions, -8 deletions)
View changed files
📝
src/SharpCompress/Common/Zip/ZipFilePart.cs(+3 -8)📝
tests/SharpCompress.Test/Zip/ZipReaderTests.cs(+17 -0)➕
tests/TestArchives/Archives/Zip.none.encrypted.zip(+0 -0)📄 Description
ZipFilePart.CreateDecompressionStreamwhen called withZipCompressionMethod.Nonewould wrap the passed in stream in aReadOnlySubstream(if it wasn't one already) and return that. In case of encrypted zip files, that stream was aWinzipAesCryptoStreamwhich needs to be disposed for it to finish reading the entry data, howeverReadOnlySubstreamnever disposes its underlying stream, causing failure when trying to read further.I've adjusted the logic to never wrap the passed in stream in a
ReadOnlySubstreamwhich seems to be fine with the existing logic and ensures the stream is always disposed if necessary. I'm not 100% this is the correct thing to do, but it's really hard to determine who has ownership over which stream and what component should be responsible for disposal, so hopefully unconditionally not wrapping the stream is fine here.I've added a test to make sure this won't regress in the future.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.