On Tue, 1 Dec 2026 07:00:49 GMT, Timofei Fedotov <[email protected]> wrote:
>> 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 two > additional commits since the last revision: > > - Convert ZIP64 regression test to JUnit > - Validate ZIP64 directory fields in findEND test/jdk/java/util/zip/ZipFile/NegativeZip64CentralDirectorySize.java line 67: > 65: buffer.putShort(ZIP64_END_OFFSET + 14, (short) 45); > 66: > 67: // Set the ZIP64 central directory size to -1. It looks this test (and the other test for ZipFile) exercise the cenlen < 0 case. Can we test the cenoff < 0 case too (or maybe I missed it in the two tests). ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/34122#discussion_r4751148455
