Integrated: 8349914: ZipFile::entries and ZipFile::getInputStream not consistent with each other when there are duplicate entries

Jaikiran Pai jpai at openjdk.org
Fri Jun 6 02:10:12 UTC 2025


On Wed, 4 Jun 2025 09:53:13 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:

> Can I please get a review of this change which proposes to address the issue noted in https://bugs.openjdk.org/browse/JDK-8349914?
> 
> The ZIP specification allows for more than one entry to have the same file name (and may have different file data). In such situation, as noted in the linked issue, the `ZipFile.getInputStream(ZipEntry)` may end up picking up an "incorrect" entry content (and metadata) for the passed entry.
> 
> The commit in this PR addresses that issue by holding on to the LOC offset of the entry in the `ZipEntry` class. This way, whenever that `ZipEntry` instance is used, it knows which exact entry it represents.
> 
> A new jtreg test has been introduced to reproduce the issue and verify the fix. The new test and existing tests in tier1, tier2 and tier3 pass with this change.

This pull request has now been integrated.

Changeset: 029e3bf8
Author:    Jaikiran Pai <jpai at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/029e3bf8f582f7399b80c592421b2fd72737e264
Stats:     237 lines in 3 files changed: 233 ins; 0 del; 4 mod

8349914: ZipFile::entries and ZipFile::getInputStream not consistent with each other when there are duplicate entries

Co-authored-by: Lance Andersen <lancea at openjdk.org>
Reviewed-by: lancea

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

PR: https://git.openjdk.org/jdk/pull/25635


More information about the core-libs-dev mailing list