5

Most of the time this code works, however, about 1/3 of the time, it gets about 80% of the way through and fails. The unzipping fails when unzipping xray image files. (They are numbered files with no file extension.) It seems to be able to handle them most of the time, however, every once in a while there is an xray that it fails to unzip on. When it fails on the file, it gives it a random filename with a random extension. It appears to be hitting a character combination that it doesn't understand while unzipping.

It is specifically happening with aes encrypted zip files. If they send the same files zipped without aes encryption, then the program unzips them just fine.

When I manually unzip the same zip file using the 7zip application, I enter the same password and it works just fine.

Ex. File should be: 00043 ==> Unzip failure yields: 1hzcqoee.nss

Error Message:

The final hash has not been computed.

Stack Trace:

at Ionic.Zip.WinZipAesCipherStream.get_FinalAuthentication() at Ionic.Zip.ZipEntry.VerifyCrcAfterExtract(Int32 calculatedCrc32, EncryptionAlgorithm encryptionAlgorithm, Int32 expectedCrc32, Stream archiveStream, Int64 uncompressedSize) at Ionic.Zip.ZipEntry.ExtractToStream(Stream archiveStream, Stream output, EncryptionAlgorithm encryptionAlgorithm, Int32 expectedCrc32) at Ionic.Zip.ZipEntry.InternalExtractToBaseDir(String baseDir, String password, ZipContainer zipContainer, ZipEntrySource zipEntrySource, String fileName) at Ionic.Zip.ZipFile._InternalExtractAll(String path, Boolean overrideExtractExistingProperty) at RHASystem64.ProcessNewVisitUpload.ExtractZip(String zipToUnpack, String unpackDirectory)

Code:

using Ionic.Zip;
public bool ExtractZip(string zipToUnpack, string unpackDirectory)
{
    using (ZipFile zip1 = ZipFile.Read(zipToUnpack))
    {
        foreach (ZipEntry z in zip1)
        {
            if (z.FileName.Contains(".mdf"))
            {
                foundMDF = true;
                isEncrypted = z.UsesEncryption;
            }
        }
        if(isEncrypted)
            zip1.Password = zipPass;

        zip1.ExtractAll(unpackDirectory, ExtractExistingFileAction.DoNotOverwrite);
        ExtractSuccess = true;
    }
    return ExtractSuccess;
}

I even tried adding a second attempt with the following line and it yields the same results.

zip1.ParallelDeflateThreshold = -1;

Has anyone dealt with this error before? Please help me figure this hash error out! Thank you!

Mr.Robot
  • 123
  • 2
  • 16
  • same thing happens to me, not often but it does. Any luck in finding the reason or workaround? – Alex Apr 06 '21 at 21:18

1 Answers1

1

in case it happens to someone else, it was a bug and it got fixed https://github.com/haf/DotNetZip.Semverd/issues/201 so, update your nuget.

Alex
  • 836
  • 9
  • 19