On Wed, 2 Dec 2026 05:40:54 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: > > Address ZIP64 regression test review comments test/jdk/java/util/zip/ZipFile/NegativeZip64CentralDirectorySize.java line 77: > 75: > 76: @TempDir > 77: Path tempDir; For jtreg tests, the jtreg framework manages temporary scratch directories for each test. That scratch directory is the "current working directory" with which the test gets launched. So whenever creating a temporary directory/file, you can always use the current working directory as the parent directory and jtreg will then manage the cleanup of that directory appropriately. So this usage of `@TempDir` isn't strictly necessary and the call sites in this test can use something like: return Files.write(Path.of("negative-zip64.zip"), archive(negativeOffset)); instead of return Files.write(tempDir.resolve("negative-zip64.zip"), archive(negativeOffset)); test/jdk/java/util/zip/ZipFile/NegativeZip64CentralDirectorySize.java line 124: > 122: @ParameterizedTest > 123: @ValueSource(booleans = {false, true}) > 124: public void zipFile(boolean negativeOffset) throws IOException { A different test method name like `testZipFile` along with a brief comment on the test method stating what the test does with the `java.util.zip.ZipFile` would be better. Same comment for the rest of the test methods. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/34122#discussion_r4770158315 PR Review Comment: https://git.openjdk.org/jdk/pull/34122#discussion_r4770190690
