|
1 | 1 | /* |
2 | | - * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2009, 2026, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 | 4 | * |
5 | 5 | * This code is free software; you can redistribute it and/or modify it |
@@ -1233,7 +1233,7 @@ private void endRead() { |
1233 | 1233 |
|
1234 | 1234 | private volatile boolean isOpen = true; |
1235 | 1235 | private final SeekableByteChannel ch; // channel to the zipfile |
1236 | | - final byte[] cen; // CEN & ENDHDR |
| 1236 | + final byte[] cen; // CEN |
1237 | 1237 | private END end; |
1238 | 1238 | private long locpos; // position of first LOC header (usually 0) |
1239 | 1239 |
|
@@ -1585,15 +1585,15 @@ private byte[] initCEN() throws IOException { |
1585 | 1585 | if (locpos < 0) |
1586 | 1586 | throw new ZipException("invalid END header (bad central directory offset)"); |
1587 | 1587 |
|
1588 | | - // read in the CEN and END |
1589 | | - byte[] cen = new byte[(int)(end.cenlen + ENDHDR)]; |
1590 | | - if (readNBytesAt(cen, 0, cen.length, cenpos) != end.cenlen + ENDHDR) { |
| 1588 | + // read in the CEN |
| 1589 | + byte[] cen = new byte[(int)(end.cenlen)]; |
| 1590 | + if (readNBytesAt(cen, 0, cen.length, cenpos) != end.cenlen) { |
1591 | 1591 | throw new ZipException("read CEN tables failed"); |
1592 | 1592 | } |
1593 | 1593 | // Iterate through the entries in the central directory |
1594 | 1594 | inodes = LinkedHashMap.newLinkedHashMap(end.centot + 1); |
1595 | 1595 | int pos = 0; |
1596 | | - int limit = cen.length - ENDHDR; |
| 1596 | + int limit = cen.length; |
1597 | 1597 | while (pos < limit) { |
1598 | 1598 | if (!cenSigAt(cen, pos)) |
1599 | 1599 | throw new ZipException("invalid CEN header (bad signature)"); |
@@ -1641,7 +1641,7 @@ private byte[] initCEN() throws IOException { |
1641 | 1641 | // skip ext and comment |
1642 | 1642 | pos += (CENHDR + nlen + elen + clen); |
1643 | 1643 | } |
1644 | | - if (pos + ENDHDR != cen.length) { |
| 1644 | + if (pos != cen.length) { |
1645 | 1645 | throw new ZipException("invalid CEN header (bad header size)"); |
1646 | 1646 | } |
1647 | 1647 | buildNodeTree(); |
@@ -1671,7 +1671,7 @@ private void checkExtraFields( byte[] cen, int cenPos, long size, long csize, |
1671 | 1671 | } |
1672 | 1672 | // CEN Offset where this Extra field ends |
1673 | 1673 | int extraEndOffset = startingOffset + extraFieldLen; |
1674 | | - if (extraEndOffset > cen.length - ENDHDR) { |
| 1674 | + if (extraEndOffset > cen.length) { |
1675 | 1675 | zerror("Invalid CEN header (extra data field size too long)"); |
1676 | 1676 | } |
1677 | 1677 | int currentOffset = startingOffset; |
|
0 commit comments