On Tue, 1 Dec 2026 09:19:26 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 one 
> additional commit since the last revision:
> 
>   Extend ZIP64 regression test to cover negative offsets

Thank you for the updates.  Similar comments as made for  8398547

test/jdk/java/util/zip/ZipFile/NegativeZip64CentralDirectorySize.java line 92:

> 90:                 ? "negative-zip64-offset.zip"
> 91:                 : "negative-zip64-size.zip";
> 92:         return Files.write(tempDir.resolve(name), 
> archive(negativeOffset));

As each test run is unique, we do not need multiple names for the zip files

test/jdk/java/util/zip/ZipFile/NegativeZip64CentralDirectorySize.java line 97:

> 95:     @Test
> 96:     public void zipFile() throws IOException {
> 97:         for (boolean negativeOffset : new boolean[] {false, true}) {

This should be a ParamertizedTest

-------------

PR Review: https://git.openjdk.org/jdk/pull/34122#pullrequestreview-6137005901
PR Review Comment: https://git.openjdk.org/jdk/pull/34122#discussion_r4758721768
PR Review Comment: https://git.openjdk.org/jdk/pull/34122#discussion_r4758713081

Reply via email to