Skip to content

Commit 8ecf238

Browse files
authored
Merge pull request #248 from keithc-ca/v0.40.1
Merge latest changes from jdk-17.0.8.1+1
2 parents 77b0f75 + 6e8bbf7 commit 8ecf238

File tree

7 files changed

+1002
-17
lines changed

7 files changed

+1002
-17
lines changed

.jcheck/conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[general]
22
project=jdk-updates
33
jbs=JDK
4-
version=17.0.8
4+
version=17.0.8.1
55

66
[checks]
77
error=author,committer,reviewers,merge,issues,executable,symlink,message,hg-tag,whitespace,problemlists

closed/openjdk-tag.gmk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
OPENJDK_TAG := jdk-17.0.8+7
1+
OPENJDK_TAG := jdk-17.0.8.1+1

make/conf/version-numbers.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@
2929
DEFAULT_VERSION_FEATURE=17
3030
DEFAULT_VERSION_INTERIM=0
3131
DEFAULT_VERSION_UPDATE=8
32-
DEFAULT_VERSION_PATCH=0
32+
DEFAULT_VERSION_PATCH=1
3333
DEFAULT_VERSION_EXTRA1=0
3434
DEFAULT_VERSION_EXTRA2=0
3535
DEFAULT_VERSION_EXTRA3=0
36-
DEFAULT_VERSION_DATE=2023-07-18
36+
DEFAULT_VERSION_DATE=2023-08-24
3737
DEFAULT_VERSION_CLASSFILE_MAJOR=61 # "`$EXPR $DEFAULT_VERSION_FEATURE + 44`"
3838
DEFAULT_VERSION_CLASSFILE_MINOR=0
3939
DEFAULT_VERSION_DOCS_API_SINCE=11

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

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@
6969
import jdk.internal.ref.CleanerFactory;
7070
import jdk.internal.vm.annotation.Stable;
7171
import sun.nio.cs.UTF_8;
72-
import sun.security.action.GetBooleanAction;
72+
import sun.nio.fs.DefaultFileSystemProvider;
73+
import sun.security.action.GetPropertyAction;
7374
import sun.security.util.SignatureFileVerifier;
7475

7576
import static java.util.zip.ZipConstants64.*;
@@ -123,11 +124,12 @@ public class ZipFile implements ZipConstants, Closeable {
123124
public static final int OPEN_DELETE = 0x4;
124125

125126
/**
126-
* Flag which specifies whether the validation of the Zip64 extra
127-
* fields should be disabled
127+
* Flag to specify whether the Extra ZIP64 validation should be
128+
* disabled.
128129
*/
129-
private static final boolean disableZip64ExtraFieldValidation =
130-
GetBooleanAction.privilegedGetProperty("jdk.util.zip.disableZip64ExtraFieldValidation");
130+
private static final boolean DISABLE_ZIP64_EXTRA_VALIDATION =
131+
getDisableZip64ExtraFieldValidation();
132+
131133
/**
132134
* Opens a zip file for reading.
133135
*
@@ -1086,6 +1088,21 @@ private int[] getMetaInfVersions() {
10861088
}
10871089

10881090
private static boolean isWindows;
1091+
/**
1092+
* Returns the value of the System property which indicates whether the
1093+
* Extra ZIP64 validation should be disabled.
1094+
*/
1095+
static boolean getDisableZip64ExtraFieldValidation() {
1096+
boolean result;
1097+
String value = GetPropertyAction.privilegedGetProperty(
1098+
"jdk.util.zip.disableZip64ExtraFieldValidation");
1099+
if (value == null) {
1100+
result = false;
1101+
} else {
1102+
result = value.isEmpty() || value.equalsIgnoreCase("true");
1103+
}
1104+
return result;
1105+
}
10891106

10901107
static {
10911108
SharedSecrets.setJavaUtilZipFileAccess(
@@ -1204,7 +1221,7 @@ private int checkAndAddEntry(int pos, int index)
12041221
}
12051222

12061223
int elen = CENEXT(cen, pos);
1207-
if (elen > 0 && !disableZip64ExtraFieldValidation) {
1224+
if (elen > 0 && !DISABLE_ZIP64_EXTRA_VALIDATION) {
12081225
long extraStartingOffset = pos + CENHDR + nlen;
12091226
if ((int)extraStartingOffset != extraStartingOffset) {
12101227
zerror("invalid CEN header (bad extra offset)");
@@ -1248,25 +1265,32 @@ private void checkExtraFields(int cenPos, int startingOffset,
12481265
zerror("Invalid CEN header (extra data field size too long)");
12491266
}
12501267
int currentOffset = startingOffset;
1251-
while (currentOffset < extraEndOffset) {
1268+
// Walk through each Extra Header. Each Extra Header Must consist of:
1269+
// Header ID - 2 bytes
1270+
// Data Size - 2 bytes:
1271+
while (currentOffset + Integer.BYTES <= extraEndOffset) {
12521272
int tag = get16(cen, currentOffset);
12531273
currentOffset += Short.BYTES;
12541274

12551275
int tagBlockSize = get16(cen, currentOffset);
1276+
currentOffset += Short.BYTES;
12561277
int tagBlockEndingOffset = currentOffset + tagBlockSize;
12571278

12581279
// The ending offset for this tag block should not go past the
12591280
// offset for the end of the extra field
12601281
if (tagBlockEndingOffset > extraEndOffset) {
1261-
zerror("Invalid CEN header (invalid zip64 extra data field size)");
1282+
zerror(String.format(
1283+
"Invalid CEN header (invalid extra data field size for " +
1284+
"tag: 0x%04x at %d)",
1285+
tag, cenPos));
12621286
}
1263-
currentOffset += Short.BYTES;
12641287

12651288
if (tag == ZIP64_EXTID) {
12661289
// Get the compressed size;
12671290
long csize = CENSIZ(cen, cenPos);
12681291
// Get the uncompressed size;
12691292
long size = CENLEN(cen, cenPos);
1293+
12701294
checkZip64ExtraFieldValues(currentOffset, tagBlockSize,
12711295
csize, size);
12721296
}
@@ -1290,6 +1314,16 @@ private void checkZip64ExtraFieldValues(int off, int blockSize, long csize,
12901314
long size)
12911315
throws ZipException {
12921316
byte[] cen = this.cen;
1317+
// if ZIP64_EXTID blocksize == 0, which may occur with some older
1318+
// versions of Apache Ant and Commons Compress, validate csize and size
1319+
// to make sure neither field == ZIP64_MAGICVAL
1320+
if (blockSize == 0) {
1321+
if (csize == ZIP64_MAGICVAL || size == ZIP64_MAGICVAL) {
1322+
zerror("Invalid CEN header (invalid zip64 extra data field size)");
1323+
}
1324+
// Only validate the ZIP64_EXTID data if the block size > 0
1325+
return;
1326+
}
12931327
// Validate the Zip64 Extended Information Extra Field (0x0001)
12941328
// length.
12951329
if (!isZip64ExtBlockSizeValid(blockSize)) {

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3078,10 +3078,22 @@ private void readExtra(ZipFileSystem zipfs) throws IOException {
30783078
int sz = SH(extra, pos + 2);
30793079
pos += 4;
30803080
if (pos + sz > elen) { // invalid data
3081-
throw new ZipException("Invalid CEN header (invalid zip64 extra data field size)");
3081+
throw new ZipException(String.format(
3082+
"Invalid CEN header (invalid extra data field size for " +
3083+
"tag: 0x%04x size: %d)",
3084+
tag, sz));
30823085
}
30833086
switch (tag) {
30843087
case EXTID_ZIP64 :
3088+
// if ZIP64_EXTID blocksize == 0, which may occur with some older
3089+
// versions of Apache Ant and Commons Compress, validate csize
3090+
// size, and locoff to make sure the fields != ZIP64_MAGICVAL
3091+
if (sz == 0) {
3092+
if (csize == ZIP64_MINVAL || size == ZIP64_MINVAL || locoff == ZIP64_MINVAL) {
3093+
throw new ZipException("Invalid CEN header (invalid zip64 extra data field size)");
3094+
}
3095+
break;
3096+
}
30853097
// Check to see if we have a valid block size
30863098
if (!isZip64ExtBlockSizeValid(sz)) {
30873099
throw new ZipException("Invalid CEN header (invalid zip64 extra data field size)");

test/jdk/java/util/zip/ZipFile/CorruptedZipFiles.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323

2424
/* @test
25-
* @bug 4770745 6218846 6218848 6237956
25+
* @bug 4770745 6218846 6218848 6237956 8313765
2626
* @summary test for correct detection and reporting of corrupted zip files
2727
* @author Martin Buchholz
2828
*/
@@ -113,8 +113,9 @@ public static void main(String[] args) throws Exception {
113113

114114
err.println("corrupted CENEXT 1");
115115
bad = good.clone();
116-
bad[cenpos+CENEXT]++;
117-
checkZipException(bad, ".*invalid zip64 extra data field size.*");
116+
bad[cenpos+CENEXT] = (byte)0xff;
117+
bad[cenpos+CENEXT+1] = (byte)0xff;
118+
checkZipException(bad, ".*extra data field size too long.*");
118119

119120
err.println("corrupted CENEXT 2");
120121
bad = good.clone();

0 commit comments

Comments
 (0)