Skip to content

Commit 8438c58

Browse files
committed
8336844: ZipConstants64 defines duplicate constants EXTID_ZIP64 and ZIP64_EXTID
Reviewed-by: jpai, vtewari, lancea
1 parent c1c9704 commit 8438c58

File tree

6 files changed

+10
-12
lines changed

6 files changed

+10
-12
lines changed

src/java.base/share/classes/java/util/zip/ZipConstants64.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1995, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -40,7 +40,6 @@ class ZipConstants64 {
4040
static final int ZIP64_ENDHDR = 56; // ZIP64 end header size
4141
static final int ZIP64_LOCHDR = 20; // ZIP64 end loc header size
4242
static final int ZIP64_EXTHDR = 24; // EXT header size
43-
static final int ZIP64_EXTID = 0x0001; // Extra field Zip64 header ID
4443

4544
static final int ZIP64_MAGICCOUNT = 0xFFFF;
4645
static final long ZIP64_MAGICVAL = 0xFFFFFFFFL;

src/java.base/share/classes/java/util/zip/ZipFile.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,7 +1324,7 @@ private void checkExtraFields(int cenPos, int startingOffset,
13241324
tag, cenPos));
13251325
}
13261326

1327-
if (tag == ZIP64_EXTID) {
1327+
if (tag == EXTID_ZIP64) {
13281328
// Get the compressed size;
13291329
long csize = CENSIZ(cen, cenPos);
13301330
// Get the uncompressed size;
@@ -1360,15 +1360,15 @@ private void checkZip64ExtraFieldValues(int off, int blockSize, long csize,
13601360
long size, long locoff, int diskNo)
13611361
throws ZipException {
13621362
byte[] cen = this.cen;
1363-
// if ZIP64_EXTID blocksize == 0, which may occur with some older
1363+
// if EXTID_ZIP64 blocksize == 0, which may occur with some older
13641364
// versions of Apache Ant and Commons Compress, validate csize and size
13651365
// to make sure neither field == ZIP64_MAGICVAL
13661366
if (blockSize == 0) {
13671367
if (csize == ZIP64_MAGICVAL || size == ZIP64_MAGICVAL ||
13681368
locoff == ZIP64_MAGICVAL || diskNo == ZIP64_MAGICCOUNT) {
13691369
zerror("Invalid CEN header (invalid zip64 extra data field size)");
13701370
}
1371-
// Only validate the ZIP64_EXTID data if the block size > 0
1371+
// Only validate the EXTID_ZIP64 data if the block size > 0
13721372
return;
13731373
}
13741374
// Validate the Zip64 Extended Information Extra Field (0x0001)

src/java.base/share/classes/java/util/zip/ZipInputStream.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ private boolean expect64BitDataDescriptor(byte[] extra, int flag, long csize, lo
679679
if (i + headerSize + dsize > extra.length) {
680680
return false; // Invalid size
681681
}
682-
if (id == ZIP64_EXTID) {
682+
if (id == EXTID_ZIP64) {
683683
return true;
684684
}
685685
i += headerSize + dsize;

src/java.base/share/classes/java/util/zip/ZipOutputStream.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ private void writeLOC(XEntry xentry) throws IOException {
485485
writeShort(elen);
486486
writeBytes(nameBytes, 0, nameBytes.length);
487487
if (hasZip64) {
488-
writeShort(ZIP64_EXTID);
488+
writeShort(EXTID_ZIP64);
489489
writeShort(16);
490490
writeLong(e.size);
491491
writeLong(e.csize);
@@ -643,7 +643,7 @@ private void writeCEN(XEntry xentry) throws IOException {
643643

644644
// take care of EXTID_ZIP64 and EXTID_EXTT
645645
if (hasZip64) {
646-
writeShort(ZIP64_EXTID);// Zip64 extra
646+
writeShort(EXTID_ZIP64);// Zip64 extra
647647
writeShort(elenZIP64);
648648
if (size == ZIP64_MAGICVAL)
649649
writeLong(e.size);

src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipConstants.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2009, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -130,7 +130,6 @@ class ZipConstants {
130130
static final int ZIP64_ENDHDR = 56; // ZIP64 end header size
131131
static final int ZIP64_LOCHDR = 20; // ZIP64 end loc header size
132132
static final int ZIP64_EXTHDR = 24; // EXT header size
133-
static final int ZIP64_EXTID = 0x0001; // Extra field Zip64 header ID
134133

135134
static final int ZIP64_MINVAL32 = 0xFFFF;
136135
static final long ZIP64_MINVAL = 0xFFFFFFFFL;

src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1710,15 +1710,15 @@ private void checkExtraFields( byte[] cen, int cenPos, long size, long csize,
17101710
private void checkZip64ExtraFieldValues(byte[] cen, int off, int blockSize, long csize,
17111711
long size, long locoff, int diskNo)
17121712
throws ZipException {
1713-
// if ZIP64_EXTID blocksize == 0, which may occur with some older
1713+
// if EXTID_ZIP64 blocksize == 0, which may occur with some older
17141714
// versions of Apache Ant and Commons Compress, validate csize and size
17151715
// to make sure neither field == ZIP64_MAGICVAL
17161716
if (blockSize == 0) {
17171717
if (csize == ZIP64_MINVAL || size == ZIP64_MINVAL ||
17181718
locoff == ZIP64_MINVAL || diskNo == ZIP64_MINVAL32) {
17191719
zerror("Invalid CEN header (invalid zip64 extra data field size)");
17201720
}
1721-
// Only validate the ZIP64_EXTID data if the block size > 0
1721+
// Only validate the EXTID_ZIP64 data if the block size > 0
17221722
return;
17231723
}
17241724
// Validate the Zip64 Extended Information Extra Field (0x0001)

0 commit comments

Comments
 (0)