Recent ZipArchive changes destroy performance on all non-zip archives #72

Closed
opened 2026-01-29 22:06:10 +00:00 by claunia · 1 comment
Owner

Originally created by @benshoof on GitHub (Dec 15, 2015).

A critical bug has been recently introduced that causes SharpCompress to read and process the entirety of all non-zip archives when opening them. This affects both Archive and Reader APIs.

0f12a073af causes ZipArchive.IsZipFile() to scan the entire archive looking for a zip header instead of returning immediately after not finding it at the start. Since the first thing that ArchiveFactory.Open() and ReaderFactory.Open() do is call ZipArchvie.IsZipFile(), all non-zip archives pay this price. Even worse, the header search is CPU bound so it takes much longer than simply reading the entire file. Zip files open quickly though since they pass the test right away. The committer probably only tested this on zip files and small non-zip files.

This commit needs to be reverted.

Originally created by @benshoof on GitHub (Dec 15, 2015). A critical bug has been recently introduced that causes SharpCompress to read and process the entirety of all non-zip archives when opening them. This affects both Archive and Reader APIs. 0f12a073af4486509dfd777da1854efb5dc571ee causes ZipArchive.IsZipFile() to scan the entire archive looking for a zip header instead of returning immediately after not finding it at the start. Since the first thing that ArchiveFactory.Open() and ReaderFactory.Open() do is call ZipArchvie.IsZipFile(), all non-zip archives pay this price. Even worse, the header search is CPU bound so it takes much longer than simply reading the entire file. Zip files open quickly though since they pass the test right away. The committer probably only tested this on zip files and small non-zip files. This commit needs to be reverted.
Author
Owner

@adamhathcock commented on GitHub (Dec 15, 2015):

Can you do this for me? I'm fighting fires at work.

@adamhathcock commented on GitHub (Dec 15, 2015): Can you do this for me? I'm fighting fires at work.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#72