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

NotImplemented exception thrown on AES unzip. #188

Closed
BertusVanZyl opened this issue Aug 31, 2017 · 6 comments
Closed

NotImplemented exception thrown on AES unzip. #188

BertusVanZyl opened this issue Aug 31, 2017 · 6 comments
Labels
bug encryption zip Related to ZIP file format

Comments

@BertusVanZyl
Copy link

BertusVanZyl commented Aug 31, 2017

Steps to reproduce

using (FileStream fs = File.OpenRead(fileName))
{
    var zf = new ZipFile(fs);
    zf.Password = "aaa";
    foreach (ZipEntry zipEntry in zf)
    {
        if (!zipEntry.IsFile)
        {
            continue; // Ignore directories
        }
        
        byte[] buffer = new byte[zipEntry.Size];
        try
        {
            using (Stream zipStream = zf.GetInputStream(zipEntry))
            {
                zipStream.Read(buffer, 0, buffer.Length);
            }
        }
        catch (Exception ex)
        {
            //NotImplemented thrown on dispose from using block.
        }
    }
}

Expected behavior

The bytes are read from the stream successfully, so the functionality IS implemented. The exception should not be thrown.

Actual behavior

NotImplemented exception is thrown.

Version of SharpZipLib

0.86.0 nuget package.

Obtained from (place an x between the brackets for all that apply)

  • Package installed using:
  • NuGet
@BertusVanZyl
Copy link
Author

Here is an example zip. the password is "aaa'.

aaa.zip

@wsloth
Copy link

wsloth commented Sep 8, 2017

I have this same problem with the following code:

var zipFile = new ZipFile(zipStream)
{
    Password = "Some Encryption Password"
};

foreach (ZipEntry entry in zipFile)
{
    if (!entry.IsFile) continue;

    string content;
    var zipInputStream = zipFile.GetInputStream(entry);

    // Read file contents
    using (var s = new StreamReader(zipInputStream, Encoding.UTF8))
    {
        content = s.ReadToEnd(); // The file content is properly read without problems
    } // exception is thrown here
}

It seems to me the exception occurs here:

throw new NotImplementedException("ZipAESTransform.TransformFinalBlock");

@piksel piksel added bug encryption zip Related to ZIP file format labels May 12, 2018
@stealthrabbi
Copy link

So what should someone do, given this bug? I can get the input stream and read from it. But we can't close it. Should we call it and catch the exception, or just leave it open? If we're unzipping a large file, I'm concerned about leaving all those stream open. Or, is it sufficient to close the contraining stream (e.g. MemoryStream) that is passed to ZipFile ?

@piksel
Copy link
Member

piksel commented Sep 16, 2018

I don't know. This is planned to be fixed for v1.1, and is currently listed as not working as per #35.

I have not been able to work on it for a while though.

@BertusVanZyl
Copy link
Author

BertusVanZyl commented Nov 1, 2019

I cannot reproduce this problem in 1.2.0. I don't know in which version it was fixed.

@piksel
Copy link
Member

piksel commented Dec 30, 2019

It was fixed in v1.1, thanks for updating (closing) the issue!

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

No branches or pull requests

4 participants