FULL PRODUCT VERSION : java version "1.8.0_40" Java(TM) SE Runtime Environment (build 1.8.0_40-b26) Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode) ADDITIONAL OS VERSION INFORMATION : Microsoft Windows [Version 6.1.7601] A DESCRIPTION OF THE PROBLEM : When attempting to unzip a data file an ArrayIndexOutOfBoundsException is thrown when iterating over the contents of the zip file. The file begins the following: 50 4b 03 04 14 00 00 00 00 00 8c bc 5c 44 00 00 00 00 00 00 00 00 00 00 00 00 0d 00 2c 00 4e 44 44 46 20 50 6c 75 73 20 44 42 2f 4e 55 20 00 4e 55 43 58 0d 00 4e 00 44 00 44 00 46 00 20 00 50 00 6c 00 75 00 73 00 20 00 44 00 42 00 2f 00 0a 00 04 00 00 00 00 00 50 4b 03 04 14 00 00 00 00 00 8c bc 5c 44 00 00 00 00 00 00 00 00 00 00 00 REGRESSION. Last worked in version 7u76 ADDITIONAL REGRESSION INFORMATION: c:\Program Files (x86)\Java\jre7\bin>java -version java version "1.7.0_76" Java(TM) SE Runtime Environment (build 1.7.0_76-b13) Java HotSpot(TM) Client VM (build 24.76-b04, mixed mode, sharing) STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : Run included test program with a zip file containing XCeed unicode extra field data. The application will crash. I can provide a sample zip file upon request EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - Tthe application will succeed in unzipping the files into the destination directory. ACTUAL - The actual results were the stack trace listed in the logs. ERROR MESSAGES/STACK TRACES THAT OCCUR : UnzipTest>java Unzipper Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 46 at java.util.zip.ZipUtils.get16(Unknown Source) at java.util.zip.ZipEntry.setExtra0(Unknown Source) at java.util.zip.ZipInputStream.readLOC(Unknown Source) at java.util.zip.ZipInputStream.getNextEntry(Unknown Source) at Unzipper.main(Unzipper.java:34) REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- import java.io.File; import java.io.ByteArrayInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; public class Unzipper { public static void main(String[] args) throws IOException { DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMMddHHmmss"); String now = LocalDateTime.now().format(df); String WORKPATH = "C:\\maidev\\FDBUpdate\\"; String DATAPATH = WORKPATH + "DATA_" + now + "\\"; String FDB_FILENAME = "NDDF Plus UPD.zip"; // Unzip String unzipPath = WORKPATH + FDB_FILENAME; Path filePath = Paths.get(unzipPath); byte[] fileBytes = Files.readAllBytes(filePath); ByteArrayInputStream bytes = new ByteArrayInputStream(fileBytes); ZipInputStream zis = new ZipInputStream(bytes); ZipEntry entry; while ((entry = zis.getNextEntry()) != null) { int count; int n = entry.getName().lastIndexOf("/"); String filename = entry.getName().substring(n + 1); File fileOut = new File(DATAPATH + filename); if (entry.isDirectory()) { fileOut.mkdirs(); } else { byte[] buffer = (byte[]) java.lang.reflect.Array.newInstance(java.lang.Byte .TYPE, 1024); FileOutputStream fos = new FileOutputStream(fileOut); // read byte content from zipped file while ((count = zis.read(buffer, 0, 1024)) != -1) { fos.write(buffer, 0, count); } fos.close(); } } zis.close(); } } ---------- END SOURCE ----------
|