Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
338d57c7
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看板
提交
338d57c7
编写于
7月 22, 2010
作者:
M
michaelm
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6952603: NetworkInterface reveals local network address to untrusted code
Reviewed-by: chegar
上级
a09538be
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
34 addition
and
9 deletion
+34
-9
src/share/classes/java/net/NetworkInterface.java
src/share/classes/java/net/NetworkInterface.java
+34
-9
未找到文件。
src/share/classes/java/net/NetworkInterface.java
浏览文件 @
338d57c7
...
...
@@ -86,7 +86,9 @@ public final class NetworkInterface {
* If there is a security manager, its <code>checkConnect</code>
* method is called for each InetAddress. Only InetAddresses where
* the <code>checkConnect</code> doesn't throw a SecurityException
* will be returned in the Enumeration.
* will be returned in the Enumeration. However, if the caller has the
* {@link NetPermission}("getNetworkInformation") permission, then all
* InetAddresses are returned.
* @return an Enumeration object with all or a subset of the InetAddresses
* bound to this network interface
*/
...
...
@@ -99,11 +101,19 @@ public final class NetworkInterface {
checkedAddresses
()
{
local_addrs
=
new
InetAddress
[
addrs
.
length
];
boolean
trusted
=
true
;
SecurityManager
sec
=
System
.
getSecurityManager
();
if
(
sec
!=
null
)
{
try
{
sec
.
checkPermission
(
new
NetPermission
(
"getNetworkInformation"
));
}
catch
(
SecurityException
e
)
{
trusted
=
false
;
}
}
for
(
int
j
=
0
;
j
<
addrs
.
length
;
j
++)
{
try
{
if
(
sec
!=
null
)
{
if
(
sec
!=
null
&&
!
trusted
)
{
sec
.
checkConnect
(
addrs
[
j
].
getHostAddress
(),
-
1
);
}
local_addrs
[
count
++]
=
addrs
[
j
];
...
...
@@ -402,13 +412,29 @@ public final class NetworkInterface {
/**
* Returns the hardware address (usually MAC) of the interface if it
* has one and if it can be accessed given the current privileges.
* If a security manager is set, then the caller must have
* the permission {@link NetPermission}("getNetworkInformation").
*
* @return a byte array containing the address, or <code>null</code> if
* the address doesn't exist, is not accessible or a security
* manager is set and the caller does not have the permission
* NetPermission("getNetworkInformation")
*
* @return a byte array containing the address or <code>null</code> if
* the address doesn't exist or is not accessible.
* @exception SocketException if an I/O error occurs.
* @since 1.6
*/
public
byte
[]
getHardwareAddress
()
throws
SocketException
{
SecurityManager
sec
=
System
.
getSecurityManager
();
if
(
sec
!=
null
)
{
try
{
sec
.
checkPermission
(
new
NetPermission
(
"getNetworkInformation"
));
}
catch
(
SecurityException
e
)
{
if
(!
getInetAddresses
().
hasMoreElements
())
{
// don't have connect permission to any local address
return
null
;
}
}
}
for
(
InetAddress
addr
:
addrs
)
{
if
(
addr
instanceof
Inet4Address
)
{
return
getMacAddr0
(((
Inet4Address
)
addr
).
getAddress
(),
name
,
index
);
...
...
@@ -523,11 +549,10 @@ public final class NetworkInterface {
}
public
int
hashCode
()
{
int
count
=
0
;
if
(
addrs
!=
null
)
{
for
(
int
i
=
0
;
i
<
addrs
.
length
;
i
++)
{
count
+=
addrs
[
i
].
hashCode
();
}
int
count
=
name
==
null
?
0
:
name
.
hashCode
();
Enumeration
<
InetAddress
>
addrs
=
getInetAddresses
();
while
(
addrs
.
hasMoreElements
())
{
count
+=
addrs
.
nextElement
().
hashCode
();
}
return
count
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录