Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
6b50399a
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看板
提交
6b50399a
编写于
13年前
作者:
M
michaelm
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6981922: DNS cache poisoning by untrusted applets
Reviewed-by: chegar
上级
1612bc52
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
134 addition
and
11 deletion
+134
-11
make/sun/net/FILES_java.gmk
make/sun/net/FILES_java.gmk
+2
-1
src/share/classes/java/net/AbstractPlainDatagramSocketImpl.java
...are/classes/java/net/AbstractPlainDatagramSocketImpl.java
+10
-1
src/share/classes/java/net/AbstractPlainSocketImpl.java
src/share/classes/java/net/AbstractPlainSocketImpl.java
+21
-1
src/share/classes/sun/net/ResourceManager.java
src/share/classes/sun/net/ResourceManager.java
+82
-0
src/share/classes/sun/nio/ch/DatagramChannelImpl.java
src/share/classes/sun/nio/ch/DatagramChannelImpl.java
+16
-6
src/share/classes/sun/nio/ch/Net.java
src/share/classes/sun/nio/ch/Net.java
+3
-2
未找到文件。
make/sun/net/FILES_java.gmk
浏览文件 @
6b50399a
#
# Copyright (c) 1996, 201
0
, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 1996, 201
1
, 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
...
...
@@ -34,6 +34,7 @@ FILES_java = \
sun/net/ProgressListener.java \
sun/net/ProgressMeteringPolicy.java \
sun/net/SocksProxy.java \
sun/net/ResourceManager.java \
sun/net/TelnetInputStream.java \
sun/net/TelnetOutputStream.java \
sun/net/TelnetProtocolException.java \
...
...
This diff is collapsed.
Click to expand it.
src/share/classes/java/net/AbstractPlainDatagramSocketImpl.java
浏览文件 @
6b50399a
...
...
@@ -28,6 +28,7 @@ import java.io.FileDescriptor;
import
java.io.IOException
;
import
java.io.InterruptedIOException
;
import
java.util.Enumeration
;
import
sun.net.ResourceManager
;
/**
* Abstract datagram and multicast socket implementation base class.
...
...
@@ -66,7 +67,14 @@ abstract class AbstractPlainDatagramSocketImpl extends DatagramSocketImpl
*/
protected
synchronized
void
create
()
throws
SocketException
{
fd
=
new
FileDescriptor
();
datagramSocketCreate
();
ResourceManager
.
beforeUdpCreate
();
try
{
datagramSocketCreate
();
}
catch
(
SocketException
ioe
)
{
ResourceManager
.
afterUdpClose
();
fd
=
null
;
throw
ioe
;
}
}
/**
...
...
@@ -211,6 +219,7 @@ abstract class AbstractPlainDatagramSocketImpl extends DatagramSocketImpl
protected
void
close
()
{
if
(
fd
!=
null
)
{
datagramSocketClose
();
ResourceManager
.
afterUdpClose
();
fd
=
null
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/share/classes/java/net/AbstractPlainSocketImpl.java
浏览文件 @
6b50399a
...
...
@@ -32,6 +32,7 @@ import java.io.FileDescriptor;
import
sun.net.ConnectionResetException
;
import
sun.net.NetHooks
;
import
sun.net.ResourceManager
;
/**
* Default Socket Implementation. This implementation does
...
...
@@ -68,6 +69,10 @@ abstract class AbstractPlainSocketImpl extends SocketImpl
private
int
resetState
;
private
final
Object
resetLock
=
new
Object
();
/* whether this Socket is a stream (TCP) socket or not (UDP)
*/
private
boolean
stream
;
/**
* Load net library into runtime.
*/
...
...
@@ -82,7 +87,19 @@ abstract class AbstractPlainSocketImpl extends SocketImpl
*/
protected
synchronized
void
create
(
boolean
stream
)
throws
IOException
{
fd
=
new
FileDescriptor
();
socketCreate
(
stream
);
this
.
stream
=
stream
;
if
(!
stream
)
{
ResourceManager
.
beforeUdpCreate
();
try
{
socketCreate
(
false
);
}
catch
(
IOException
ioe
)
{
ResourceManager
.
afterUdpClose
();
fd
=
null
;
throw
ioe
;
}
}
else
{
socketCreate
(
true
);
}
if
(
socket
!=
null
)
socket
.
setCreated
();
if
(
serverSocket
!=
null
)
...
...
@@ -479,6 +496,9 @@ abstract class AbstractPlainSocketImpl extends SocketImpl
protected
void
close
()
throws
IOException
{
synchronized
(
fdLock
)
{
if
(
fd
!=
null
)
{
if
(!
stream
)
{
ResourceManager
.
afterUdpClose
();
}
if
(
fdUseCount
==
0
)
{
if
(
closePending
)
{
return
;
...
...
This diff is collapsed.
Click to expand it.
src/share/classes/sun/net/ResourceManager.java
0 → 100644
浏览文件 @
6b50399a
/*
* Copyright (c) 2011, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package
sun.net
;
import
java.net.SocketException
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
sun.security.action.GetPropertyAction
;
/**
* Manages count of total number of UDP sockets and ensures
* that exception is thrown if we try to create more than the
* configured limit.
*
* This functionality could be put in NetHooks some time in future.
*/
public
class
ResourceManager
{
/* default maximum number of udp sockets per VM
* when a security manager is enabled.
* The default is 1024 which is high enough to be useful
* but low enough to be well below the maximum number
* of port numbers actually available on all OSes for
* such sockets (5000 on some versions of windows)
*/
private
static
final
int
DEFAULT_MAX_SOCKETS
=
1024
;
private
static
final
int
maxSockets
;
private
static
final
AtomicInteger
numSockets
;
static
{
String
prop
=
java
.
security
.
AccessController
.
doPrivileged
(
new
GetPropertyAction
(
"sun.net.maxDatagramSockets"
)
);
int
defmax
=
DEFAULT_MAX_SOCKETS
;
try
{
if
(
prop
!=
null
)
{
defmax
=
Integer
.
parseInt
(
prop
);
}
}
catch
(
NumberFormatException
e
)
{}
maxSockets
=
defmax
;
numSockets
=
new
AtomicInteger
(
0
);
}
public
static
void
beforeUdpCreate
()
throws
SocketException
{
if
(
System
.
getSecurityManager
()
!=
null
)
{
if
(
numSockets
.
incrementAndGet
()
>
maxSockets
)
{
numSockets
.
decrementAndGet
();
throw
new
SocketException
(
"maximum number of DatagramSockets reached"
);
}
}
}
public
static
void
afterUdpClose
()
{
if
(
System
.
getSecurityManager
()
!=
null
)
{
numSockets
.
decrementAndGet
();
}
}
}
This diff is collapsed.
Click to expand it.
src/share/classes/sun/nio/ch/DatagramChannelImpl.java
浏览文件 @
6b50399a
...
...
@@ -32,6 +32,7 @@ import java.nio.ByteBuffer;
import
java.nio.channels.*
;
import
java.nio.channels.spi.*
;
import
java.util.*
;
import
sun.net.ResourceManager
;
/**
...
...
@@ -101,14 +102,22 @@ class DatagramChannelImpl
throws
IOException
{
super
(
sp
);
this
.
family
=
Net
.
isIPv6Available
()
?
StandardProtocolFamily
.
INET6
:
StandardProtocolFamily
.
INET
;
this
.
fd
=
Net
.
socket
(
family
,
false
);
this
.
fdVal
=
IOUtil
.
fdVal
(
fd
);
this
.
state
=
ST_UNCONNECTED
;
ResourceManager
.
beforeUdpCreate
();
try
{
this
.
family
=
Net
.
isIPv6Available
()
?
StandardProtocolFamily
.
INET6
:
StandardProtocolFamily
.
INET
;
this
.
fd
=
Net
.
socket
(
family
,
false
);
this
.
fdVal
=
IOUtil
.
fdVal
(
fd
);
this
.
state
=
ST_UNCONNECTED
;
}
catch
(
IOException
ioe
)
{
ResourceManager
.
afterUdpClose
();
throw
ioe
;
}
}
public
DatagramChannelImpl
(
SelectorProvider
sp
,
ProtocolFamily
family
)
{
public
DatagramChannelImpl
(
SelectorProvider
sp
,
ProtocolFamily
family
)
throws
IOException
{
super
(
sp
);
if
((
family
!=
StandardProtocolFamily
.
INET
)
&&
(
family
!=
StandardProtocolFamily
.
INET6
))
...
...
@@ -957,6 +966,7 @@ class DatagramChannelImpl
protected
void
implCloseSelectableChannel
()
throws
IOException
{
synchronized
(
stateLock
)
{
nd
.
preClose
(
fd
);
ResourceManager
.
afterUdpClose
();
// if member of mulitcast group then invalidate all keys
if
(
registry
!=
null
)
...
...
This diff is collapsed.
Click to expand it.
src/share/classes/sun/nio/ch/Net.java
浏览文件 @
6b50399a
...
...
@@ -312,11 +312,12 @@ class Net { // package-private
private
static
native
boolean
canJoin6WithIPv4Group0
();
static
FileDescriptor
socket
(
boolean
stream
)
{
static
FileDescriptor
socket
(
boolean
stream
)
throws
IOException
{
return
socket
(
UNSPEC
,
stream
);
}
static
FileDescriptor
socket
(
ProtocolFamily
family
,
boolean
stream
)
{
static
FileDescriptor
socket
(
ProtocolFamily
family
,
boolean
stream
)
throws
IOException
{
boolean
preferIPv6
=
isIPv6Available
()
&&
(
family
!=
StandardProtocolFamily
.
INET
);
return
IOUtil
.
newFD
(
socket0
(
preferIPv6
,
stream
,
false
));
...
...
This diff is collapsed.
Click to expand it.
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录
新手
引导
客服
返回
顶部