Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
52e58b86
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看板
提交
52e58b86
编写于
10月 16, 2013
作者:
R
robm
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8026245: InetAddress.getLocalHost crash if IPv6 disabled (macosx)
Reviewed-by: chegar, alanb
上级
6016e36e
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
24 addition
and
36 deletion
+24
-36
src/solaris/native/java/net/Inet4AddressImpl.c
src/solaris/native/java/net/Inet4AddressImpl.c
+2
-2
src/solaris/native/java/net/Inet6AddressImpl.c
src/solaris/native/java/net/Inet6AddressImpl.c
+13
-30
test/java/net/InetAddress/GetLocalHostWithSM.java
test/java/net/InetAddress/GetLocalHostWithSM.java
+4
-2
test/java/net/Socket/GetLocalAddress.java
test/java/net/Socket/GetLocalAddress.java
+5
-2
未找到文件。
src/solaris/native/java/net/Inet4AddressImpl.c
浏览文件 @
52e58b86
...
...
@@ -70,6 +70,8 @@ static void initializeInetClasses(JNIEnv *env)
#if defined(_ALLBSD_SOURCE) && !defined(HAS_GLIBC_GETHOSTBY_R)
extern
jobjectArray
lookupIfLocalhost
(
JNIEnv
*
env
,
const
char
*
hostname
,
jboolean
includeV6
);
/* Use getaddrinfo(3), which is thread safe */
/************************************************************************
* Inet4AddressImpl
...
...
@@ -378,8 +380,6 @@ Java_java_net_Inet4AddressImpl_getLocalHostName(JNIEnv *env, jobject this) {
return
(
*
env
)
->
NewStringUTF
(
env
,
hostname
);
}
extern
jobjectArray
lookupIfLocalhost
(
JNIEnv
*
env
,
const
char
*
hostname
,
jboolean
includeV6
);
/*
* Find an internet address for a given hostname. Note that this
* code only works for addresses of type INET. The translation
...
...
src/solaris/native/java/net/Inet6AddressImpl.c
浏览文件 @
52e58b86
...
...
@@ -122,9 +122,11 @@ static jclass ni_ia4cls;
static
jclass
ni_ia6cls
;
static
jmethodID
ni_ia4ctrID
;
static
jmethodID
ni_ia6ctrID
;
static
jboolean
preferIPv6Address
;
static
void
initializeInetClasses
(
JNIEnv
*
env
)
{
jfieldID
ni_preferIPv6AddressID
;
static
int
initialized
=
0
;
if
(
!
initialized
)
{
ni_iacls
=
(
*
env
)
->
FindClass
(
env
,
"java/net/InetAddress"
);
...
...
@@ -135,6 +137,10 @@ static void initializeInetClasses(JNIEnv *env)
ni_ia6cls
=
(
*
env
)
->
NewGlobalRef
(
env
,
ni_ia6cls
);
ni_ia4ctrID
=
(
*
env
)
->
GetMethodID
(
env
,
ni_ia4cls
,
"<init>"
,
"()V"
);
ni_ia6ctrID
=
(
*
env
)
->
GetMethodID
(
env
,
ni_ia6cls
,
"<init>"
,
"()V"
);
ni_preferIPv6AddressID
=
(
*
env
)
->
GetStaticFieldID
(
env
,
ni_iacls
,
"preferIPv6Address"
,
"Z"
);
preferIPv6Address
=
(
*
env
)
->
GetStaticBooleanField
(
env
,
ia_class
,
ia_preferIPv6AddressID
);
initialized
=
1
;
}
}
...
...
@@ -145,7 +151,6 @@ __private_extern__ jobjectArray
lookupIfLocalhost
(
JNIEnv
*
env
,
const
char
*
hostname
,
jboolean
includeV6
)
{
jobjectArray
result
=
NULL
;
jboolean
preferIPv6Address
;
char
myhostname
[
NI_MAXHOST
+
1
];
struct
ifaddrs
*
ifa
=
NULL
;
int
familyOrder
=
0
;
...
...
@@ -157,9 +162,6 @@ lookupIfLocalhost(JNIEnv *env, const char *hostname, jboolean includeV6)
// Make sure static variables we need are set.
initializeInetClasses
(
env
);
/* get the address preference */
preferIPv6Address
=
(
*
env
)
->
GetStaticBooleanField
(
env
,
ia_class
,
ia_preferIPv6AddressID
);
/* If the requested name matches this host's hostname, return IP addresses
* from all attached interfaces. (#2844683 et al) This prevents undesired
* PPP dialup, but may return addresses that don't actually correspond to
...
...
@@ -278,7 +280,6 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
const
char
*
hostname
;
jobjectArray
ret
=
0
;
int
retLen
=
0
;
jboolean
preferIPv6Address
;
int
error
=
0
;
#ifdef AF_INET6
...
...
@@ -296,36 +297,18 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
#ifdef MACOSX
/*
* If
getaddrinfo has failed and we're looking up the local machine, we
*
attempt to get the address from getifaddrs. This ensures we get an
*
IPv6 address for the local
machine.
* If
we're looking up the local machine, attempt to get the address
*
from getifaddrs. This ensures we get an IPv6 address for the local
* machine.
*/
if
(
error
)
{
ret
=
lookupIfLocalhost
(
env
,
hostname
,
JNI_TRUE
);
if
(
ret
!=
NULL
||
(
*
env
)
->
ExceptionCheck
(
env
))
{
JNU_ReleaseStringPlatformChars
(
env
,
host
,
hostname
);
return
ret
;
}
}
#endif
#ifdef AF_INET6
static
jfieldID
ia_preferIPv6AddressID
;
if
(
ia_preferIPv6AddressID
==
NULL
)
{
jclass
c
=
(
*
env
)
->
FindClass
(
env
,
"java/net/InetAddress"
);
if
(
c
)
{
ia_preferIPv6AddressID
=
(
*
env
)
->
GetStaticFieldID
(
env
,
c
,
"preferIPv6Address"
,
"Z"
);
}
if
(
ia_preferIPv6AddressID
==
NULL
)
{
JNU_ReleaseStringPlatformChars
(
env
,
host
,
hostname
);
return
NULL
;
}
}
/* get the address preference */
preferIPv6Address
=
(
*
env
)
->
GetStaticBooleanField
(
env
,
ia_class
,
ia_preferIPv6AddressID
);
/* Try once, with our static buffer. */
memset
(
&
hints
,
0
,
sizeof
(
hints
));
hints
.
ai_flags
=
AI_CANONNAME
;
...
...
test/java/net/InetAddress/GetLocalHostWithSM.java
浏览文件 @
52e58b86
/*
* Copyright (c) 2002, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 201
3
, 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
...
...
@@ -23,9 +23,11 @@
/**
* @test
* @bug 4531817
* @bug 4531817
8026245
* @summary Inet[46]Address.localHost need doPrivileged
* @run main/othervm GetLocalHostWithSM
* @run main/othervm -Djava.net.preferIPv4Stack=true GetLocalHostWithSM
* @run main/othervm -Djava.net.preferIPv6Addresses=true GetLocalHostWithSM
* files needed: GetLocalHostWithSM.java, MyPrincipal.java, and policy.file
*/
...
...
test/java/net/Socket/GetLocalAddress.java
浏览文件 @
52e58b86
/*
* Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998,
2013,
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
...
...
@@ -23,7 +23,10 @@
/*
* @test
* @bug 4106601
* @bug 4106601 8026245
* @run main/othervm GetLocalAddress
* @run main/othervm -Djava.net.preferIPv4Stack=true GetLocalAddress
* @run main/othervm -Djava.net.preferIPv6Addresses=true GetLocalAddress
* @summary Test the java.net.socket.GetLocalAddress method
*
*/
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录