Loading... (original) (raw)

FULL PRODUCT VERSION :
java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Mac OS 10.9.3

A DESCRIPTION OF THE PROBLEM :
On some zip files this error is thrown when reading:

Exception in thread "main" java.util.zip.ZipException: invalid entry size (expected 0 but got 355764 bytes)

REGRESSION. Last worked in version 7u55

ADDITIONAL REGRESSION INFORMATION:
So far any jdk8 version tested.

java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Standard code to read Zip files.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No error should occur.
ACTUAL -
An exception is thrown.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
$ java ZipReader simple.zip
Entry: QuickLook/Thumbnail.jpg len 4254 added 05/03/13
Entry: QuickLook/Preview.pdf len 8102 added 05/03/13
Entry: buildVersionHistory.plist len 355 added 05/03/13
Entry: index.xml len 0 added 05/03/13
Exception in thread "main" java.util.zip.ZipException: invalid entry size (expected 0 but got 355764 bytes)
at java.util.zip.ZipInputStream.readEnd(ZipInputStream.java:383)
at java.util.zip.ZipInputStream.read(ZipInputStream.java:196)
at java.io.FilterInputStream.read(FilterInputStream.java:107)
at ZipReader.main(ZipReader.java:47)

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.Date;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

public class ZipReader
{
// Parse the supplied .zip file
public static void main(String args[]) throws Exception {
if (args.length != 1) {
System.err.println("zipreader zipfile");
return;
}

byte[] buffer = new byte[2048];

// open the zip file stream
InputStream theFile = new FileInputStream(args[0]);
ZipInputStream stream = new ZipInputStream(theFile);

try {
// Just iterate through each zip file entry
ZipEntry entry;
while((entry = stream.getNextEntry()) != null) {
String s = String.format("Entry: %s len %d added %TD",
entry.getName(), entry.getSize(),
new Date(entry.getTime()));
System.out.println(s);

int len = 0;
while ((len = stream.read(buffer)) > 0) {
// NOTHING
}
}
} finally {
stream.close();
}
}
}

// There does not appear to be any option I can see here to upload a sample zip that causes the problem.

---------- END SOURCE ----------