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

Commit

Permalink
[GR-38378] Merge in jdk-17.0.4+6.
Browse files Browse the repository at this point in the history
PullRequest: labsjdk-ce-17/46
  • Loading branch information
marwan-hallaoui committed Jun 8, 2022
2 parents da628f0 + 4b1bd54 commit 353a1ae
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 50 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/submit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ jobs:

- name: Install cygwin
run: |
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
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
- name: Checkout the source
uses: actions/checkout@v3
Expand Down Expand Up @@ -1024,7 +1024,7 @@ jobs:

- name: Install cygwin
run: |
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
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
- name: Checkout the source
uses: actions/checkout@v3
Expand Down Expand Up @@ -1207,7 +1207,7 @@ jobs:

- name: Install cygwin
run: |
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
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
- name: Restore jtreg artifact
id: jtreg_restore
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2022, 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
Expand Down Expand Up @@ -63,6 +63,7 @@
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.zip.ZipException;

import javax.lang.model.SourceVersion;
import javax.tools.FileObject;
Expand Down Expand Up @@ -564,7 +565,11 @@ public ArchiveContainer(Path archivePath) throws IOException, ProviderNotFoundEx
Map<String,String> env = Collections.singletonMap("multi-release", multiReleaseValue);
FileSystemProvider jarFSProvider = fsInfo.getJarFSProvider();
Assert.checkNonNull(jarFSProvider, "should have been caught before!");
this.fileSystem = jarFSProvider.newFileSystem(archivePath, env);
try {
this.fileSystem = jarFSProvider.newFileSystem(archivePath, env);
} catch (ZipException ze) {
throw new IOException("ZipException opening \"" + archivePath.getFileName() + "\": " + ze.getMessage(), ze);
}
} else {
this.fileSystem = FileSystems.newFileSystem(archivePath, (ClassLoader)null);
}
Expand Down
83 changes: 38 additions & 45 deletions src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ class ZipFileSystem extends FileSystem {
this.forceEnd64 = isTrue(env, "forceZIP64End");
this.defaultCompressionMethod = getDefaultCompressionMethod(env);
this.supportPosix = isTrue(env, PROPERTY_POSIX);
this.defaultOwner = initOwner(zfpath, env);
this.defaultGroup = initGroup(zfpath, env);
this.defaultPermissions = initPermissions(env);
this.defaultOwner = supportPosix ? initOwner(zfpath, env) : null;
this.defaultGroup = supportPosix ? initGroup(zfpath, env) : null;
this.defaultPermissions = supportPosix ? initPermissions(env) : null;
this.supportedFileAttributeViews = supportPosix ?
Set.of("basic", "posix", "zip") : Set.of("basic", "zip");
if (Files.notExists(zfpath)) {
Expand Down Expand Up @@ -1575,9 +1575,9 @@ private byte[] initCEN() throws IOException {
throw new ZipException("invalid CEN header (bad header size)");
}
IndexNode inode = new IndexNode(cen, pos, nlen);
if (hasDotOrDotDot(inode.name)) {
if (inode.pathHasDotOrDotDot()) {
throw new ZipException("ZIP file can't be opened as a file system " +
"because an entry has a '.' or '..' element in its name");
"because entry \"" + inode.nameAsString() + "\" has a '.' or '..' element in its name");
}
inodes.put(inode, inode);
if (zc.isUTF8() || (flag & FLAG_USE_UTF8) != 0) {
Expand All @@ -1595,44 +1595,6 @@ private byte[] initCEN() throws IOException {
return cen;
}

/**
* Check Inode.name to see if it includes a "." or ".." in the name array
* @param path the path as stored in Inode.name to verify
* @return true if the path contains a "." or ".." entry; false otherwise
*/
private boolean hasDotOrDotDot(byte[] path) {
// Inode.name always includes "/" in path[0]
assert path[0] == '/';
if (path.length == 1) {
return false;
}
int index = 1;
while (index < path.length) {
int starting = index;
while (index < path.length && path[index] != '/') {
index++;
}
// Check the path snippet for a "." or ".."
if (isDotOrDotDotPath(path, starting, index)) {
return true;
}
index++;
}
return false;
}

/**
* Check the path to see if it includes a "." or ".."
* @param path the path to check
* @return true if the path contains a "." or ".." entry; false otherwise
*/
private boolean isDotOrDotDotPath(byte[] path, int start, int index) {
int pathLen = index - start;
if ((pathLen == 1 && path[start] == '.'))
return true;
return (pathLen == 2 && path[start] == '.') && path[start + 1] == '.';
}

private final void checkUTF8(byte[] a) throws ZipException {
try {
int end = a.length;
Expand Down Expand Up @@ -2653,6 +2615,37 @@ boolean isDir() {
return isdir;
}

/**
* Check name if it contains a "." or ".." path element
* @return true if the path contains a "." or ".." entry; false otherwise
*/
private boolean pathHasDotOrDotDot() {
// name always includes "/" in path[0]
assert name[0] == '/';
if (name.length == 1) {
return false;
}
int index = 1;
while (index < name.length) {
int start = index;
while (index < name.length && name[index] != '/') {
index++;
}
if (name[start] == '.') {
int len = index - start;
if (len == 1 || (name[start + 1] == '.' && len == 2)) {
return true;
}
}
index++;
}
return false;
}

protected String nameAsString() {
return new String(name);
}

@Override
public boolean equals(Object other) {
if (!(other instanceof IndexNode)) {
Expand All @@ -2671,7 +2664,7 @@ public int hashCode() {

@Override
public String toString() {
return new String(name) + (isdir ? " (dir)" : " ") + ", index: " + pos;
return nameAsString() + (isdir ? " (dir)" : " ") + ", index: " + pos;
}
}

Expand Down Expand Up @@ -3207,7 +3200,7 @@ private void readLocEXTT(ZipFileSystem zipfs) throws IOException {
public String toString() {
StringBuilder sb = new StringBuilder(1024);
Formatter fm = new Formatter(sb);
fm.format(" name : %s%n", new String(name));
fm.format(" name : %s%n", nameAsString());
fm.format(" creationTime : %tc%n", creationTime().toMillis());
fm.format(" lastAccessTime : %tc%n", lastAccessTime().toMillis());
fm.format(" lastModifiedTime: %tc%n", lastModifiedTime().toMillis());
Expand Down

0 comments on commit 353a1ae

Please sign in to comment.