RFR: 8354799: ZipInputStream doesn't verify CRC for ZIP entry with empty file data [v3]

Shaojin Wen swen at openjdk.org
Tue May 20 23:10:56 UTC 2025


On Mon, 12 May 2025 11:27:35 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:

>> Can I please get a review of this change which addresses the issue noted in https://bugs.openjdk.org/browse/JDK-8354799?
>> 
>> `java.util.zip.ZipInputStream` when dealing with a `STORED` entry of zero size was missing a CRC check for that entry. The change in this PR addresses that and introduces a new jtreg test which reproduces the issue and verifies the fix.
>> 
>> tier testing is currently in progress.
>
> Jaikiran Pai has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Lance's suggestion - simplify argument creation, given just a handful number of argument values

src/java.base/share/classes/java/util/zip/ZipInputStream.java line 430:

> 428:                     throw new ZipException("invalid entry CRC (expected 0x"
> 429:                             + Long.toHexString(currentEntry.crc)
> 430:                             + " but got 0x" + Long.toHexString(crc.getValue()) + ")");

Suggestion:

                    throw new ZipException("invalid entry CRC (expected 0x%x but got 0x%x)".formatted(currentEntry.crc, crc.getValue()));

Can String::formatted be used here?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25116#discussion_r2099003883


More information about the core-libs-dev mailing list