Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
cf79f02c
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
cf79f02c
编写于
3月 25, 2019
作者:
M
michaelm
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8218573: Better socket support
Reviewed-by: alanb, ahgross, chegar, igerasim
上级
835fb4e9
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
48 addition
and
2 deletion
+48
-2
src/share/classes/java/net/NetPermission.java
src/share/classes/java/net/NetPermission.java
+10
-1
src/share/classes/java/net/ServerSocket.java
src/share/classes/java/net/ServerSocket.java
+15
-0
src/share/classes/java/net/Socket.java
src/share/classes/java/net/Socket.java
+18
-0
src/share/classes/sun/security/util/SecurityConstants.java
src/share/classes/sun/security/util/SecurityConstants.java
+5
-1
未找到文件。
src/share/classes/java/net/NetPermission.java
浏览文件 @
cf79f02c
/*
/*
* Copyright (c) 1997, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 201
9
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -151,6 +151,15 @@ have access to. Thus it might be able to trick the system into
...
@@ -151,6 +151,15 @@ have access to. Thus it might be able to trick the system into
creating a ProtectionDomain/CodeSource for a class even though
creating a ProtectionDomain/CodeSource for a class even though
that class really didn't come from that location.</td>
that class really didn't come from that location.</td>
* </tr>
* </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>
* </table>
* </table>
*
*
* @see java.security.BasicPermission
* @see java.security.BasicPermission
...
...
src/share/classes/java/net/ServerSocket.java
浏览文件 @
cf79f02c
...
@@ -31,6 +31,8 @@ import java.nio.channels.ServerSocketChannel;
...
@@ -31,6 +31,8 @@ import java.nio.channels.ServerSocketChannel;
import
java.security.AccessController
;
import
java.security.AccessController
;
import
java.security.PrivilegedExceptionAction
;
import
java.security.PrivilegedExceptionAction
;
import
sun.security.util.SecurityConstants
;
/**
/**
* This class implements server sockets. A server socket waits for
* This class implements server sockets. A server socket waits for
* requests to come in over the network. It performs some operation
* requests to come in over the network. It performs some operation
...
@@ -71,12 +73,25 @@ class ServerSocket implements java.io.Closeable {
...
@@ -71,12 +73,25 @@ class ServerSocket implements java.io.Closeable {
/**
/**
* Package-private constructor to create a ServerSocket associated with
* Package-private constructor to create a ServerSocket associated with
* the given SocketImpl.
* 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
)
{
ServerSocket
(
SocketImpl
impl
)
{
checkPermission
();
this
.
impl
=
impl
;
this
.
impl
=
impl
;
impl
.
setServerSocket
(
this
);
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.
* Creates an unbound server socket.
*
*
...
...
src/share/classes/java/net/Socket.java
浏览文件 @
cf79f02c
...
@@ -25,6 +25,8 @@
...
@@ -25,6 +25,8 @@
package
java.net
;
package
java.net
;
import
sun.security.util.SecurityConstants
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.io.OutputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
...
@@ -159,9 +161,14 @@ class Socket implements java.io.Closeable {
...
@@ -159,9 +161,14 @@ class Socket implements java.io.Closeable {
*
*
* @exception SocketException if there is an error in the underlying protocol,
* @exception SocketException if there is an error in the underlying protocol,
* such as a TCP error.
* 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 JDK1.1
* @since JDK1.1
*/
*/
protected
Socket
(
SocketImpl
impl
)
throws
SocketException
{
protected
Socket
(
SocketImpl
impl
)
throws
SocketException
{
checkPermission
(
impl
);
this
.
impl
=
impl
;
this
.
impl
=
impl
;
if
(
impl
!=
null
)
{
if
(
impl
!=
null
)
{
checkOldImpl
();
checkOldImpl
();
...
@@ -169,6 +176,17 @@ class Socket implements java.io.Closeable {
...
@@ -169,6 +176,17 @@ class Socket implements java.io.Closeable {
}
}
}
}
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
* Creates a stream socket and connects it to the specified port
* number on the named host.
* number on the named host.
...
...
src/share/classes/sun/security/util/SecurityConstants.java
浏览文件 @
cf79f02c
/*
/*
* Copyright (c) 2003, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 201
9
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -176,6 +176,10 @@ public final class SecurityConstants {
...
@@ -176,6 +176,10 @@ public final class SecurityConstants {
public
static
final
NetPermission
GET_RESPONSECACHE_PERMISSION
=
public
static
final
NetPermission
GET_RESPONSECACHE_PERMISSION
=
new
NetPermission
(
"getResponseCache"
);
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, sun.misc.Launcher
// java.lang.SecurityManager, sun.applet.AppletPanel, sun.misc.Launcher
public
static
final
RuntimePermission
CREATE_CLASSLOADER_PERMISSION
=
public
static
final
RuntimePermission
CREATE_CLASSLOADER_PERMISSION
=
new
RuntimePermission
(
"createClassLoader"
);
new
RuntimePermission
(
"createClassLoader"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录