soot-oss / soot

Soot - A Java optimization framework
GNU Lesser General Public License v2.1
2.85k stars 706 forks source link

Recent JDK 11/17/20 versions have messed-up java.util.ZipFile: Invalid CEN header #1992

Open jpstotz opened 1 year ago

jpstotz commented 1 year ago

For your information: The OpenJDK developers have messed up all recent JDK versions (released after July-17th: JDK 11, 17, 20) by changing the behavior of java.util.ZipFile when fixing the security problem JDK-8302483 (not yet released to the public). This affects especially soot when processing APK files (but may also affect other JAR files) and can cause the following exception when trying to read it using ZipFile:

Caused by: java.util.zip.ZipException: Invalid CEN header (invalid zip64 extra data field size)
        at java.base/java.util.zip.ZipFile$Source.zerror(ZipFile.java:1728)
        at java.base/java.util.zip.ZipFile$Source.checkExtraFields(ZipFile.java:1261)
        at java.base/java.util.zip.ZipFile$Source.checkAndAddEntry(ZipFile.java:1212)
        at java.base/java.util.zip.ZipFile$Source.initCEN(ZipFile.java:1667)

As a workaround you can set the system property jdk.util.zip.disableZip64ExtraFieldValidation to true, unfortunately changing it via System.setProperty(..) has no effect, therefore the only way is to set the property at startup on command-line:

java -Djdk.util.zip.disableZip64ExtraFieldValidation=true -jar myprogram.jar ...