8186464: ZipFile cannot read some InfoZip ZIP64 zip files#835
Draft
fitzsim wants to merge 1 commit into
Draft
Conversation
Co-authored-by: Andrew John Hughes <andrew@openjdk.org> Backport-of: 02b9452ed39eccdfe3210e65b17d4759333c0f15
|
👋 Welcome back fitzsim! A progress list of the required criteria for merging this PR into |
|
❗ This change is not yet ready to be integrated. |
|
This backport pull request has now been updated with issue from the original commit. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a third attempt at #452, hopefully this time with clearer background and context.
Background
In the
OpenJDK 9timeframe, thejava.util.zip.ZipFilewas rewritten to be pure Java, by:JDK-8145260 To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk
This rewrite was never backported to
OpenJDK 8and would be too invasive and risky to backport in its entirety now.This means that
OpenJDK 8'sjava.util.zip.ZipFileimplementation is backed byJNIC code, implemented injdk8u/jdk/src/share/native/java/util/zip/zip_util.c(core algorithms) andjdk8u/jdk/src/share/native/java/util/zip/ZipFile.c(JNI wrapper C code).ZipFile.cwas deleted during development ofOpenJDK 9, in theJDK-8145260commit:openjdk/jdk9u@2b91819
OpenJDK 8also contains Zip algorithms in a pure Java demo library, underjdk8u/jdk/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs, added during development ofOpenJDK 7, by:JDK-6990846 Demo: NIO.2 filesystem provider for zip/jar archives
During development of
OpenJDK 9, this pure Java code was promoted from being a demo package to being a fully-supported package, by:JDK-8038500: (zipfs) Upgrade ZIP provider to be a supported provider
It remains demo-only in
OpenJDK 8, and there are no plans to backport the promotion change toOpenJDK 8.Desired Java-to-C Backport
We would like to backport JDK-8186464: ZipFile cannot read some InfoZip ZIP64 zip files that was fixed during the development of
OpenJDK 10.OpenJDK 8users have run into this issue in real-world applications.However, the original JDK-8186464 fix was made against the pure Java
ZipFile.javaimplementation.The same logic of the pure Java JDK-8186464 fixes applies readily to the core C algorithms in
zip_util.c. Andrew has converted the Java code in the original fix to C code applied tozip_util.c.In our Red Hat RPMs, since 2020, we have been shipping and maintaining this patch.
This Red Hat internal backport patch, in addition to fixing the C code, also updates the demo pure Java code which was affected by the same issue reported in JDK-8186464.
However, this Java part of the patch is somewhat incidental, since, as established in the background section, the production/important Zip algorithms in
OpenJDK 8are the C implementations thereof.Changes
These changes have been deployed to Red Hat customers since 2020, with minor updates from time-to-time as required to keep the patch applicable.
I applied the patch, maintained by Andrew Hughes, as-is from:
https://gitlab.com/redhat/centos-stream/rpms/java-1.8.0-openjdk/-/raw/openjdk-portable-centos-9/jdk8186464-rh1433262-zip64_failure.patch?ref_type=72646f68c8ccb1bdbee3d2249abccf90980eb7d6
Testing
I confirmed that the changes to ReadZip.java exercise the new code
zip_utils.ccode and produce correct results.CI runs showed no regressions.
Newer OpenJDK versions and zip_util.c
zip_util.cstill survives in newer versions up to and including tip (i.e.,OpenJDK 27).It is used to load Zip files from the bootstrap classpath (
-Xbootclasspath), which happens during JVM bring-up, prior to Java features (such as the pure Java ZipFile implementation) being available.Conceivably newer versions of
zip_util.ccould be patched in the same was as proposed here, however no one has ever needed to load InfoZip ZIP64 zip files on the bootstrap classpath.There was not much interest when I proposed this in:
JDK-8334048: -Xbootclasspath can not read some ZIP64 zip files
openjdk/jdk#19678
(This could have subsequently become a true backport to
OpenJDK 8zip_util.c.)In summary, given that no one needs this code in
zip_util.cin new OpenJDK versions due tozip_util.conly being used in very specific circumstances, and given its importance inOpenJDK 8as backing the sole production Zip API, I think it makes more sense just to patchzip_util.conly inOpenJDK 8directly as we're proposing in this pull request.Progress
Issue
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk8u-dev.git pull/835/head:pull/835$ git checkout pull/835Update a local copy of the PR:
$ git checkout pull/835$ git pull https://git.openjdk.org/jdk8u-dev.git pull/835/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 835View PR using the GUI difftool:
$ git pr show -t 835Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk8u-dev/pull/835.diff