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 73: > 71: buffer.putInt(ZIP64_LOC_OFFSET + 16, 1); > 72: buffer.putInt(END_OFFSET, 0x06054b50); > 73: For the offsets and fields above, it would be useful to leverage the fields from open/src/java.base/share/classes/java/util/zip/ZipConstants64.java I would copy what is used into the test making it easier to follow. test/jdk/java/util/zip/ZipFile/NegativeZip64CentralDirectorySize.java line 76: > 74: // Indicate that the central directory size is stored in ZIP64 > END. > 75: buffer.putInt(END_OFFSET + 12, 0xffffffff); > 76: You can use ZIP64_MAGICVAL as a field name as seen in ZipConstants64.java ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/34122#discussion_r4758583130 PR Review Comment: https://git.openjdk.org/jdk/pull/34122#discussion_r4758595187
