Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2009, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -1233,7 +1233,7 @@ private void endRead() {

private volatile boolean isOpen = true;
private final SeekableByteChannel ch; // channel to the zipfile
final byte[] cen; // CEN & ENDHDR
final byte[] cen; // CEN
private END end;
private long locpos; // position of first LOC header (usually 0)

Expand Down Expand Up @@ -1585,15 +1585,15 @@ private byte[] initCEN() throws IOException {
if (locpos < 0)
throw new ZipException("invalid END header (bad central directory offset)");

// read in the CEN and END
byte[] cen = new byte[(int)(end.cenlen + ENDHDR)];
if (readNBytesAt(cen, 0, cen.length, cenpos) != end.cenlen + ENDHDR) {
// read in the CEN
byte[] cen = new byte[(int)(end.cenlen)];
if (readNBytesAt(cen, 0, cen.length, cenpos) != end.cenlen) {
throw new ZipException("read CEN tables failed");
}
// Iterate through the entries in the central directory
inodes = LinkedHashMap.newLinkedHashMap(end.centot + 1);
int pos = 0;
int limit = cen.length - ENDHDR;
int limit = cen.length;
while (pos < limit) {
if (!cenSigAt(cen, pos))
throw new ZipException("invalid CEN header (bad signature)");
Expand Down Expand Up @@ -1641,7 +1641,7 @@ private byte[] initCEN() throws IOException {
// skip ext and comment
pos += (CENHDR + nlen + elen + clen);
}
if (pos + ENDHDR != cen.length) {
if (pos != cen.length) {
throw new ZipException("invalid CEN header (bad header size)");
}
buildNodeTree();
Expand Down Expand Up @@ -1671,7 +1671,7 @@ private void checkExtraFields( byte[] cen, int cenPos, long size, long csize,
}
// CEN Offset where this Extra field ends
int extraEndOffset = startingOffset + extraFieldLen;
if (extraEndOffset > cen.length - ENDHDR) {
if (extraEndOffset > cen.length) {
zerror("Invalid CEN header (extra data field size too long)");
}
int currentOffset = startingOffset;
Expand Down