diff --git a/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java b/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java index ab471694890..b3db11eb1fe 100644 --- a/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java +++ b/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java @@ -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 @@ -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) @@ -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)"); @@ -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(); @@ -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;