8336844: ZipConstants64 defines duplicate constants EXTID_ZIP64 and ZIP64_EXTID

Reviewed-by: jpai, vtewari, lancea
This commit is contained in:
Liam Miller-Cushon 2024-07-22 17:20:58 +00:00
parent c1c9704268
commit 8438c5853f
6 changed files with 10 additions and 12 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2024, 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
@ -40,7 +40,6 @@ class ZipConstants64 {
static final int ZIP64_ENDHDR = 56; // ZIP64 end header size
static final int ZIP64_LOCHDR = 20; // ZIP64 end loc header size
static final int ZIP64_EXTHDR = 24; // EXT header size
static final int ZIP64_EXTID = 0x0001; // Extra field Zip64 header ID
static final int ZIP64_MAGICCOUNT = 0xFFFF;
static final long ZIP64_MAGICVAL = 0xFFFFFFFFL;

View file

@ -1324,7 +1324,7 @@ public class ZipFile implements ZipConstants, Closeable {
tag, cenPos));
}
if (tag == ZIP64_EXTID) {
if (tag == EXTID_ZIP64) {
// Get the compressed size;
long csize = CENSIZ(cen, cenPos);
// Get the uncompressed size;
@ -1360,7 +1360,7 @@ public class ZipFile implements ZipConstants, Closeable {
long size, long locoff, int diskNo)
throws ZipException {
byte[] cen = this.cen;
// if ZIP64_EXTID blocksize == 0, which may occur with some older
// if EXTID_ZIP64 blocksize == 0, which may occur with some older
// versions of Apache Ant and Commons Compress, validate csize and size
// to make sure neither field == ZIP64_MAGICVAL
if (blockSize == 0) {
@ -1368,7 +1368,7 @@ public class ZipFile implements ZipConstants, Closeable {
locoff == ZIP64_MAGICVAL || diskNo == ZIP64_MAGICCOUNT) {
zerror("Invalid CEN header (invalid zip64 extra data field size)");
}
// Only validate the ZIP64_EXTID data if the block size > 0
// Only validate the EXTID_ZIP64 data if the block size > 0
return;
}
// Validate the Zip64 Extended Information Extra Field (0x0001)

View file

@ -679,7 +679,7 @@ public class ZipInputStream extends InflaterInputStream implements ZipConstants
if (i + headerSize + dsize > extra.length) {
return false; // Invalid size
}
if (id == ZIP64_EXTID) {
if (id == EXTID_ZIP64) {
return true;
}
i += headerSize + dsize;

View file

@ -485,7 +485,7 @@ public class ZipOutputStream extends DeflaterOutputStream implements ZipConstant
writeShort(elen);
writeBytes(nameBytes, 0, nameBytes.length);
if (hasZip64) {
writeShort(ZIP64_EXTID);
writeShort(EXTID_ZIP64);
writeShort(16);
writeLong(e.size);
writeLong(e.csize);
@ -643,7 +643,7 @@ public class ZipOutputStream extends DeflaterOutputStream implements ZipConstant
// take care of EXTID_ZIP64 and EXTID_EXTT
if (hasZip64) {
writeShort(ZIP64_EXTID);// Zip64 extra
writeShort(EXTID_ZIP64);// Zip64 extra
writeShort(elenZIP64);
if (size == ZIP64_MAGICVAL)
writeLong(e.size);