kamchany / winzipaes

Automatically exported from code.google.com/p/winzipaes
0 stars 0 forks source link

Invalid CRC Entry when decrypting a 0 byte file #33

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create an encrypted file containing 1 or more empty files
2. Try to decrypt it.

What is the expected output? What do you see instead?

Empty files should be extracted. WinZip has no problem.

Instead I get 

java.util.zip.ZipException: invalid entry CRC (expected 0xffffffff but got 0x0)
    at java.util.zip.ZipInputStream.readEnd(ZipInputStream.java:396)
    at java.util.zip.ZipInputStream.read(ZipInputStream.java:156)
    at java.io.FilterInputStream.read(FilterInputStream.java:90)
    at de.idyl.crypto.zip.AesZipFileDecrypter.extractEntry(AesZipFileDecrypter.java:352)
    at de.idyl.crypto.zip.AesZipFileDecrypter.extractEntry(AesZipFileDecrypter.java:387)

What version of the product are you using? On what operating system?

winzipaes_src_20110206 on Windows XP Professional

Please provide any additional information below.

Looking at the source code I notice that the AesZipFileDecrypter class contains 
the following:

// at the end of the entry read-cycle a CRC check is performed.
// because our entry doesn't have a CRC this will result in an Exception
// we solve this by updating a CRC and pass this to the Entry.
CRC32 crc32 = new CRC32();
while (read > 0) {
    outStream.write(buffer, 0, read);
    crc32.update(buffer, 0, read);
    entry.setCrc(crc32.getValue());
    read = zipInputStream.read(buffer);
}

I presume this is failing to work as expected when the file size is 0.

Original issue reported on code.google.com by mek...@googlemail.com on 4 May 2011 at 10:26

GoogleCodeExporter commented 9 years ago
fixed

Original comment by olaf.merkert on 12 May 2011 at 6:44