> ZipFile reads the ZIP64 central directory size as a signed 64-bit value but > does not reject negative values before allocating the central directory > buffer. Values from -45 through -1 pass the existing consistency checks and > cause NegativeArraySizeException in new byte[cenlen]. > > A minimal 99-byte ZIP64 structure reproduces the issue with ZipFile and > JarFile. The same malformed archive also affects URLClassLoader and the zipfs > FileSystem implementation, which contains equivalent parsing logic. > ZipInputStream is unaffected because it does not read the central directory. > > Negative ZIP64 sizes and offsets should be rejected with ZipException or > IOException during header validation rather than causing an unchecked > allocation exception. > > > --------- > - [x] I confirm that I make this contribution in accordance with the [OpenJDK > Interim AI Policy](https://openjdk.org/legal/ai).
Timofei Fedotov has updated the pull request incrementally with one additional commit since the last revision: Document ZIP64 regression test scenarios ------------- Changes: - all: https://git.openjdk.org/jdk/pull/34122/files - new: https://git.openjdk.org/jdk/pull/34122/files/c56c4810..9c77f4da Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=34122&range=06 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=34122&range=05-06 Stats: 34 lines in 1 file changed: 25 ins; 7 del; 2 mod Patch: https://git.openjdk.org/jdk/pull/34122.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/34122/head:pull/34122 PR: https://git.openjdk.org/jdk/pull/34122
