Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception when reading an encrypted zip file containing a folder: "Stored, but compressed != uncompressed" #885

Open
bhaeussermann opened this issue Dec 13, 2024 · 1 comment
Labels
bug zip Related to ZIP file format

Comments

@bhaeussermann
Copy link

bhaeussermann commented Dec 13, 2024

Describe the bug

When I use a ZipInputStream to read a zip file that is encrypted and contains folder entries, the following exception occurs:

ICSharpCode.SharpZipLib.Zip.ZipException: 'Stored, but compressed != uncompressed'

Here is the zip file that is causing the exception. It was created using SharpZipLib and can be opened fine using other zip applications or libraries:
archive.zip

In the code below, it fails when calling GetNextEntry():

using var archive = new ZipInputStream(File.OpenRead(archiveFilePath))
{
    Password = "123456"
};
ZipEntry entry;
while ((entry = archive.GetNextEntry()) != null)
{
    Console.WriteLine(entry.Name);
}

Reproduction Code

https://dotnetfiddle.net/fXUXgR

Steps to reproduce

  1. Download the attached zip file and edit the provided code to point to that file.
  2. Run the code.

Expected behavior

The program must list the entries in the zip file without throwing an exception.

Operating System

Windows

Framework Version

.NET 7

Tags

ZIP

Additional context

No response

@github-actions github-actions bot added the zip Related to ZIP file format label Dec 13, 2024
@SourceproStudio
Copy link

SourceproStudio commented Dec 13, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug zip Related to ZIP file format
Projects
None yet
Development

No branches or pull requests

2 participants