Skip to content
This repository was archived by the owner on May 29, 2024. It is now read-only.

Commit 353a1ae

Browse files
[GR-38378] Merge in jdk-17.0.4+6.
PullRequest: labsjdk-ce-17/46
2 parents da628f0 + 4b1bd54 commit 353a1ae

File tree

3 files changed

+48
-50
lines changed

3 files changed

+48
-50
lines changed

.github/workflows/submit.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ jobs:
924924

925925
- name: Install cygwin
926926
run: |
927-
Start-Process -FilePath "$HOME\cygwin\setup-x86_64.exe" -ArgumentList "--quiet-mode --packages cygwin=3.2.0-1,autoconf,make,zip,unzip --root $HOME\cygwin\cygwin64 --local-package-dir $HOME\cygwin\packages --site http://mirrors.kernel.org/sourceware/cygwin --no-desktop --no-shortcuts --no-startmenu --no-admin" -Wait -NoNewWindow
927+
Start-Process -FilePath "$HOME\cygwin\setup-x86_64.exe" -ArgumentList "--quiet-mode --packages cygwin=3.3.5-1,autoconf,make,zip,unzip --root $HOME\cygwin\cygwin64 --local-package-dir $HOME\cygwin\packages --site http://mirrors.kernel.org/sourceware/cygwin --no-desktop --no-shortcuts --no-startmenu --no-admin" -Wait -NoNewWindow
928928
929929
- name: Checkout the source
930930
uses: actions/checkout@v3
@@ -1024,7 +1024,7 @@ jobs:
10241024

10251025
- name: Install cygwin
10261026
run: |
1027-
Start-Process -FilePath "$HOME\cygwin\setup-x86_64.exe" -ArgumentList "--quiet-mode --packages cygwin=3.2.0-1,autoconf,make,zip,unzip --root $HOME\cygwin\cygwin64 --local-package-dir $HOME\cygwin\packages --site http://mirrors.kernel.org/sourceware/cygwin --no-desktop --no-shortcuts --no-startmenu --no-admin" -Wait -NoNewWindow
1027+
Start-Process -FilePath "$HOME\cygwin\setup-x86_64.exe" -ArgumentList "--quiet-mode --packages cygwin=3.3.5-1,autoconf,make,zip,unzip --root $HOME\cygwin\cygwin64 --local-package-dir $HOME\cygwin\packages --site http://mirrors.kernel.org/sourceware/cygwin --no-desktop --no-shortcuts --no-startmenu --no-admin" -Wait -NoNewWindow
10281028
10291029
- name: Checkout the source
10301030
uses: actions/checkout@v3
@@ -1207,7 +1207,7 @@ jobs:
12071207

12081208
- name: Install cygwin
12091209
run: |
1210-
Start-Process -FilePath "$HOME\cygwin\setup-x86_64.exe" -ArgumentList "--quiet-mode --packages cygwin=3.2.0-1,autoconf,make,zip,unzip --root $HOME\cygwin\cygwin64 --local-package-dir $HOME\cygwin\packages --site http://mirrors.kernel.org/sourceware/cygwin --no-desktop --no-shortcuts --no-startmenu --no-admin" -Wait -NoNewWindow
1210+
Start-Process -FilePath "$HOME\cygwin\setup-x86_64.exe" -ArgumentList "--quiet-mode --packages cygwin=3.3.5-1,autoconf,make,zip,unzip --root $HOME\cygwin\cygwin64 --local-package-dir $HOME\cygwin\packages --site http://mirrors.kernel.org/sourceware/cygwin --no-desktop --no-shortcuts --no-startmenu --no-admin" -Wait -NoNewWindow
12111211
12121212
- name: Restore jtreg artifact
12131213
id: jtreg_restore

src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2022, 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
@@ -63,6 +63,7 @@
6363
import java.util.Set;
6464
import java.util.stream.Collectors;
6565
import java.util.stream.Stream;
66+
import java.util.zip.ZipException;
6667

6768
import javax.lang.model.SourceVersion;
6869
import javax.tools.FileObject;
@@ -564,7 +565,11 @@ public ArchiveContainer(Path archivePath) throws IOException, ProviderNotFoundEx
564565
Map<String,String> env = Collections.singletonMap("multi-release", multiReleaseValue);
565566
FileSystemProvider jarFSProvider = fsInfo.getJarFSProvider();
566567
Assert.checkNonNull(jarFSProvider, "should have been caught before!");
567-
this.fileSystem = jarFSProvider.newFileSystem(archivePath, env);
568+
try {
569+
this.fileSystem = jarFSProvider.newFileSystem(archivePath, env);
570+
} catch (ZipException ze) {
571+
throw new IOException("ZipException opening \"" + archivePath.getFileName() + "\": " + ze.getMessage(), ze);
572+
}
568573
} else {
569574
this.fileSystem = FileSystems.newFileSystem(archivePath, (ClassLoader)null);
570575
}

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

Lines changed: 38 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@ class ZipFileSystem extends FileSystem {
151151
this.forceEnd64 = isTrue(env, "forceZIP64End");
152152
this.defaultCompressionMethod = getDefaultCompressionMethod(env);
153153
this.supportPosix = isTrue(env, PROPERTY_POSIX);
154-
this.defaultOwner = initOwner(zfpath, env);
155-
this.defaultGroup = initGroup(zfpath, env);
156-
this.defaultPermissions = initPermissions(env);
154+
this.defaultOwner = supportPosix ? initOwner(zfpath, env) : null;
155+
this.defaultGroup = supportPosix ? initGroup(zfpath, env) : null;
156+
this.defaultPermissions = supportPosix ? initPermissions(env) : null;
157157
this.supportedFileAttributeViews = supportPosix ?
158158
Set.of("basic", "posix", "zip") : Set.of("basic", "zip");
159159
if (Files.notExists(zfpath)) {
@@ -1575,9 +1575,9 @@ private byte[] initCEN() throws IOException {
15751575
throw new ZipException("invalid CEN header (bad header size)");
15761576
}
15771577
IndexNode inode = new IndexNode(cen, pos, nlen);
1578-
if (hasDotOrDotDot(inode.name)) {
1578+
if (inode.pathHasDotOrDotDot()) {
15791579
throw new ZipException("ZIP file can't be opened as a file system " +
1580-
"because an entry has a '.' or '..' element in its name");
1580+
"because entry \"" + inode.nameAsString() + "\" has a '.' or '..' element in its name");
15811581
}
15821582
inodes.put(inode, inode);
15831583
if (zc.isUTF8() || (flag & FLAG_USE_UTF8) != 0) {
@@ -1595,44 +1595,6 @@ private byte[] initCEN() throws IOException {
15951595
return cen;
15961596
}
15971597

1598-
/**
1599-
* Check Inode.name to see if it includes a "." or ".." in the name array
1600-
* @param path the path as stored in Inode.name to verify
1601-
* @return true if the path contains a "." or ".." entry; false otherwise
1602-
*/
1603-
private boolean hasDotOrDotDot(byte[] path) {
1604-
// Inode.name always includes "/" in path[0]
1605-
assert path[0] == '/';
1606-
if (path.length == 1) {
1607-
return false;
1608-
}
1609-
int index = 1;
1610-
while (index < path.length) {
1611-
int starting = index;
1612-
while (index < path.length && path[index] != '/') {
1613-
index++;
1614-
}
1615-
// Check the path snippet for a "." or ".."
1616-
if (isDotOrDotDotPath(path, starting, index)) {
1617-
return true;
1618-
}
1619-
index++;
1620-
}
1621-
return false;
1622-
}
1623-
1624-
/**
1625-
* Check the path to see if it includes a "." or ".."
1626-
* @param path the path to check
1627-
* @return true if the path contains a "." or ".." entry; false otherwise
1628-
*/
1629-
private boolean isDotOrDotDotPath(byte[] path, int start, int index) {
1630-
int pathLen = index - start;
1631-
if ((pathLen == 1 && path[start] == '.'))
1632-
return true;
1633-
return (pathLen == 2 && path[start] == '.') && path[start + 1] == '.';
1634-
}
1635-
16361598
private final void checkUTF8(byte[] a) throws ZipException {
16371599
try {
16381600
int end = a.length;
@@ -2653,6 +2615,37 @@ boolean isDir() {
26532615
return isdir;
26542616
}
26552617

2618+
/**
2619+
* Check name if it contains a "." or ".." path element
2620+
* @return true if the path contains a "." or ".." entry; false otherwise
2621+
*/
2622+
private boolean pathHasDotOrDotDot() {
2623+
// name always includes "/" in path[0]
2624+
assert name[0] == '/';
2625+
if (name.length == 1) {
2626+
return false;
2627+
}
2628+
int index = 1;
2629+
while (index < name.length) {
2630+
int start = index;
2631+
while (index < name.length && name[index] != '/') {
2632+
index++;
2633+
}
2634+
if (name[start] == '.') {
2635+
int len = index - start;
2636+
if (len == 1 || (name[start + 1] == '.' && len == 2)) {
2637+
return true;
2638+
}
2639+
}
2640+
index++;
2641+
}
2642+
return false;
2643+
}
2644+
2645+
protected String nameAsString() {
2646+
return new String(name);
2647+
}
2648+
26562649
@Override
26572650
public boolean equals(Object other) {
26582651
if (!(other instanceof IndexNode)) {
@@ -2671,7 +2664,7 @@ public int hashCode() {
26712664

26722665
@Override
26732666
public String toString() {
2674-
return new String(name) + (isdir ? " (dir)" : " ") + ", index: " + pos;
2667+
return nameAsString() + (isdir ? " (dir)" : " ") + ", index: " + pos;
26752668
}
26762669
}
26772670

@@ -3207,7 +3200,7 @@ private void readLocEXTT(ZipFileSystem zipfs) throws IOException {
32073200
public String toString() {
32083201
StringBuilder sb = new StringBuilder(1024);
32093202
Formatter fm = new Formatter(sb);
3210-
fm.format(" name : %s%n", new String(name));
3203+
fm.format(" name : %s%n", nameAsString());
32113204
fm.format(" creationTime : %tc%n", creationTime().toMillis());
32123205
fm.format(" lastAccessTime : %tc%n", lastAccessTime().toMillis());
32133206
fm.format(" lastModifiedTime: %tc%n", lastModifiedTime().toMillis());

0 commit comments

Comments
 (0)