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

Commit

Permalink
Merge pull request #26 in G/labsjdk-ce-11 from ds/GR-18988 to master
Browse files Browse the repository at this point in the history
* commit '2a9c98313d8c2b14a1e14b732036f67e03e88a9a': (26 commits)
  8219914: Change the environment variable for Java Access Bridge logging to have a directory
  8228825: Enhance ECDSA operations
  8227601: Better collection of references
  8226765: Commentary on Javadoc comments
  8225597: Enhance font glyph mapping
  8225298: Improve TLS connection support
  8225292: Better Graphics2D drawing
  8225286: Better rendering of native glyphs
  8224915: Better serial attributes
  8224532: Better Path supports
  8224062: Improve String index handling
  8223892: Improved handling of jar files
  8223886: Add in font table referene
  8223518: Unexpected exception in jjs
  8223505: Better pattern compilation
  8222690: Better Glyph Images
  8222684: Better support for patterns 8223163: Better pattern recognition
  8221858: Build Better Processes
  8221497: Optional Panes in Swing
  8209901: Canonical file handling
  ...
  • Loading branch information
dougxc committed Oct 21, 2019
2 parents 85d3919 + 2a9c983 commit e18e630
Show file tree
Hide file tree
Showing 77 changed files with 1,880 additions and 409 deletions.
8 changes: 3 additions & 5 deletions src/hotspot/cpu/x86/macroAssembler_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6353,7 +6353,7 @@ void MacroAssembler::string_indexof_char(Register str1, Register cnt1, Register
movptr(result, str1);
if (UseAVX >= 2) {
cmpl(cnt1, stride);
jcc(Assembler::less, SCAN_TO_CHAR_LOOP);
jcc(Assembler::less, SCAN_TO_CHAR);
cmpl(cnt1, 2*stride);
jcc(Assembler::less, SCAN_TO_8_CHAR_INIT);
movdl(vec1, ch);
Expand All @@ -6380,10 +6380,8 @@ void MacroAssembler::string_indexof_char(Register str1, Register cnt1, Register
}
bind(SCAN_TO_8_CHAR);
cmpl(cnt1, stride);
if (UseAVX >= 2) {
jcc(Assembler::less, SCAN_TO_CHAR);
} else {
jcc(Assembler::less, SCAN_TO_CHAR_LOOP);
jcc(Assembler::less, SCAN_TO_CHAR);
if (UseAVX < 2) {
movdl(vec1, ch);
pshuflw(vec1, vec1, 0x00);
pshufd(vec1, vec1, 0);
Expand Down
44 changes: 29 additions & 15 deletions src/java.base/share/classes/java/io/FilePermission.java
Original file line number Diff line number Diff line change
Expand Up @@ -366,12 +366,22 @@ private void init(int mask) {
this.mask = mask;

if (cpath.equals("<<ALL FILES>>")) {
allFiles = true;
directory = true;
recursive = true;
cpath = "";
return;
}

// Validate path by platform's default file system
try {
String name = cpath.endsWith("*") ? cpath.substring(0, cpath.length() - 1) + "-" : cpath;
builtInFS.getPath(new File(name).getPath());
} catch (InvalidPathException ipe) {
invalid = true;
return;
}

// store only the canonical cpath if possible
cpath = AccessController.doPrivileged(new PrivilegedAction<>() {
public String run() {
Expand Down Expand Up @@ -462,6 +472,9 @@ public String run() {
* <P>
* The default value of the {@code jdk.io.permissionsUseCanonicalPath}
* system property is {@code false} in this implementation.
* <p>
* The value can also be set with a security property using the same name,
* but setting a system property will override the security property value.
*
* @param path the pathname of the file/directory.
* @param actions the action string.
Expand Down Expand Up @@ -572,19 +585,19 @@ public boolean implies(Permission p) {
* @return the effective mask
*/
boolean impliesIgnoreMask(FilePermission that) {
if (this == that) {
return true;
}
if (allFiles) {
return true;
}
if (this.invalid || that.invalid) {
return false;
}
if (that.allFiles) {
return false;
}
if (FilePermCompat.nb) {
if (this == that) {
return true;
}
if (allFiles) {
return true;
}
if (this.invalid || that.invalid) {
return false;
}
if (that.allFiles) {
return false;
}
// Left at least same level of wildness as right
if ((this.recursive && that.recursive) != that.recursive
|| (this.directory && that.directory) != that.directory) {
Expand Down Expand Up @@ -782,10 +795,10 @@ public boolean equals(Object obj) {

FilePermission that = (FilePermission) obj;

if (this.invalid || that.invalid) {
return false;
}
if (FilePermCompat.nb) {
if (this.invalid || that.invalid) {
return false;
}
return (this.mask == that.mask) &&
(this.allFiles == that.allFiles) &&
this.npath.equals(that.npath) &&
Expand All @@ -794,6 +807,7 @@ public boolean equals(Object obj) {
(this.recursive == that.recursive);
} else {
return (this.mask == that.mask) &&
(this.allFiles == that.allFiles) &&
this.cpath.equals(that.cpath) &&
(this.directory == that.directory) &&
(this.recursive == that.recursive);
Expand Down
11 changes: 10 additions & 1 deletion src/java.base/share/classes/java/net/NetPermission.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2019, 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 @@ -145,6 +145,15 @@
* </tr>
*
* <tr>
* <th scope="row">setSocketImpl</th>
* <td>The ability to create a sub-class of Socket or ServerSocket with a
* user specified SocketImpl.</td>
* <td>Malicious user-defined SocketImpls can change the behavior of
* Socket and ServerSocket in surprising ways, by virtue of their
* ability to access the protected fields of SocketImpl.</td>
* </tr>
*
* <tr>
* <th scope="row">specifyStreamHandler</th>
* <td>The ability
* to specify a stream handler when constructing a URL</td>
Expand Down
14 changes: 14 additions & 0 deletions src/java.base/share/classes/java/net/ServerSocket.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import jdk.internal.misc.JavaNetSocketAccess;
import jdk.internal.misc.SharedSecrets;
import sun.security.util.SecurityConstants;

import java.io.FileDescriptor;
import java.io.IOException;
Expand Down Expand Up @@ -78,12 +79,25 @@ class ServerSocket implements java.io.Closeable {
/**
* Package-private constructor to create a ServerSocket associated with
* the given SocketImpl.
*
* @throws SecurityException if a security manager is set and
* its {@code checkPermission} method doesn't allow
* {@code NetPermission("setSocketImpl")}.
*/
ServerSocket(SocketImpl impl) {
checkPermission();
this.impl = impl;
impl.setServerSocket(this);
}

private static Void checkPermission() {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(SecurityConstants.SET_SOCKETIMPL_PERMISSION);
}
return null;
}

/**
* Creates an unbound server socket.
*
Expand Down
18 changes: 18 additions & 0 deletions src/java.base/share/classes/java/net/Socket.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

package java.net;

import sun.security.util.SecurityConstants;

import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
Expand Down Expand Up @@ -161,16 +163,32 @@ public Socket(Proxy proxy) {
*
* @exception SocketException if there is an error in the underlying protocol,
* such as a TCP error.
*
* @throws SecurityException if {@code impl} is non-null and a security manager is set
* and its {@code checkPermission} method doesn't allow {@code NetPermission("setSocketImpl")}.
*
* @since 1.1
*/
protected Socket(SocketImpl impl) throws SocketException {
checkPermission(impl);
this.impl = impl;
if (impl != null) {
checkOldImpl();
this.impl.setSocket(this);
}
}

private static Void checkPermission(SocketImpl impl) {
if (impl == null) {
return null;
}
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(SecurityConstants.SET_SOCKETIMPL_PERMISSION);
}
return null;
}

/**
* Creates a stream socket and connects it to the specified port
* number on the named host.
Expand Down
10 changes: 10 additions & 0 deletions src/java.base/share/classes/java/net/URL.java
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,16 @@ public URL(String protocol, String host, int port, String file,
throw new MalformedURLException(s);
}
}
if ("jar".equalsIgnoreCase(protocol)) {
if (handler instanceof sun.net.www.protocol.jar.Handler) {
// URL.openConnection() would throw a confusing exception
// so generate a better exception here instead.
String s = ((sun.net.www.protocol.jar.Handler) handler).checkNestedProtocol(file);
if (s != null) {
throw new MalformedURLException(s);
}
}
}
}

/**
Expand Down
21 changes: 17 additions & 4 deletions src/java.base/share/classes/java/util/regex/Pattern.java
Original file line number Diff line number Diff line change
Expand Up @@ -1424,7 +1424,11 @@ private Pattern(String p, int f) {
localTCNCount = 0;

if (!pattern.isEmpty()) {
compile();
try {
compile();
} catch (StackOverflowError soe) {
throw error("Stack overflow during pattern compilation");
}
} else {
root = new Start(lastAccept);
matchRoot = lastAccept;
Expand Down Expand Up @@ -1963,6 +1967,10 @@ private int parsePastLine() {
int ch = temp[cursor++];
while (ch != 0 && !isLineSeparator(ch))
ch = temp[cursor++];
if (ch == 0 && cursor > patternLength) {
cursor = patternLength;
ch = temp[cursor++];
}
return ch;
}

Expand All @@ -1973,6 +1981,10 @@ private int peekPastLine() {
int ch = temp[++cursor];
while (ch != 0 && !isLineSeparator(ch))
ch = temp[++cursor];
if (ch == 0 && cursor > patternLength) {
cursor = patternLength;
ch = temp[cursor];
}
return ch;
}

Expand Down Expand Up @@ -3407,9 +3419,10 @@ private int u() {
private int N() {
if (read() == '{') {
int i = cursor;
while (cursor < patternLength && read() != '}') {}
if (cursor > patternLength)
throw error("Unclosed character name escape sequence");
while (read() != '}') {
if (cursor >= patternLength)
throw error("Unclosed character name escape sequence");
}
String name = new String(temp, i, cursor - i - 1);
try {
return Character.codePointOf(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2165,6 +2165,10 @@ public synchronized void doTunneling() throws IOException {
} while (retryTunnel < maxRedirects);

if (retryTunnel >= maxRedirects || (respCode != HTTP_OK)) {
if (respCode != HTTP_PROXY_AUTH) {
// remove all but authenticate responses
responses.reset();
}
throw new IOException("Unable to tunnel through proxy."+
" Proxy returns \"" +
statusLine + "\"");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2019, 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 @@ -121,6 +121,13 @@ protected int hashCode(URL u) {
return h;
}

public String checkNestedProtocol(String spec) {
if (spec.regionMatches(true, 0, "jar:", 0, 4)) {
return "Nested JAR URLs are not supported";
} else {
return null;
}
}

@Override
@SuppressWarnings("deprecation")
Expand All @@ -146,6 +153,12 @@ protected void parseURL(URL url, String spec,
: false;
spec = spec.substring(start, limit);

String exceptionMessage = checkNestedProtocol(spec);
if (exceptionMessage != null) {
// NPE will be transformed into MalformedURLException by the caller
throw new NullPointerException(exceptionMessage);
}

if (absoluteSpec) {
file = parseAbsoluteSpec(spec);
} else if (!refOnly) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -521,12 +521,6 @@ static class SupportedGroups {
NamedGroup.SECP256_R1,
NamedGroup.SECP384_R1,
NamedGroup.SECP521_R1,
NamedGroup.SECT283_K1,
NamedGroup.SECT283_R1,
NamedGroup.SECT409_K1,
NamedGroup.SECT409_R1,
NamedGroup.SECT571_K1,
NamedGroup.SECT571_R1,

// FFDHE 2048
NamedGroup.FFDHE_2048,
Expand All @@ -541,15 +535,6 @@ static class SupportedGroups {
NamedGroup.SECP256_R1,
NamedGroup.SECP384_R1,
NamedGroup.SECP521_R1,
NamedGroup.SECT283_K1,
NamedGroup.SECT283_R1,
NamedGroup.SECT409_K1,
NamedGroup.SECT409_R1,
NamedGroup.SECT571_K1,
NamedGroup.SECT571_R1,

// non-NIST curves
NamedGroup.SECP256_K1,

// FFDHE 2048
NamedGroup.FFDHE_2048,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2019, 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 @@ -42,8 +42,11 @@ public class FilePermCompat {
public static final boolean compat;

static {
String flag = GetPropertyAction.privilegedGetProperty(
"jdk.io.permissionsUseCanonicalPath", "false");
String flag = SecurityProperties.privilegedGetOverridable(
"jdk.io.permissionsUseCanonicalPath");
if (flag == null) {
flag = "false";
}
switch (flag) {
case "true":
nb = false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2019, 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 @@ -97,6 +97,10 @@ private SecurityConstants () {
public static final NetPermission GET_RESPONSECACHE_PERMISSION =
new NetPermission("getResponseCache");

// java.net.ServerSocket, java.net.Socket
public static final NetPermission SET_SOCKETIMPL_PERMISSION =
new NetPermission("setSocketImpl");

// java.lang.SecurityManager, sun.applet.AppletPanel
public static final RuntimePermission CREATE_CLASSLOADER_PERMISSION =
new RuntimePermission("createClassLoader");
Expand Down
Loading

0 comments on commit e18e630

Please sign in to comment.