提交 61e9fd81 编写于 作者: C chegar

6799040: Portability issues in src/solaris/native/java/net/Inet4AddressImpl.c

Reviewed-by: alanb
Contributed-by: christos@zoulas.com
上级 02e51c6b
...@@ -165,16 +165,18 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this, ...@@ -165,16 +165,18 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
hostname = JNU_GetStringPlatformChars(env, host, JNI_FALSE); hostname = JNU_GetStringPlatformChars(env, host, JNI_FALSE);
CHECK_NULL_RETURN(hostname, NULL); CHECK_NULL_RETURN(hostname, NULL);
#ifdef __solaris__
/* /*
* Workaround for Solaris bug 4160367 - if a hostname contains a * Workaround for Solaris bug 4160367 - if a hostname contains a
* white space then 0.0.0.0 is returned * white space then 0.0.0.0 is returned
*/ */
if (isspace(hostname[0])) { if (isspace((unsigned char)hostname[0])) {
JNU_ThrowByName(env, JNU_JAVANETPKG "UnknownHostException", JNU_ThrowByName(env, JNU_JAVANETPKG "UnknownHostException",
(char *)hostname); (char *)hostname);
JNU_ReleaseStringPlatformChars(env, host, hostname); JNU_ReleaseStringPlatformChars(env, host, hostname);
return NULL; return NULL;
} }
#endif
/* Try once, with our static buffer. */ /* Try once, with our static buffer. */
#ifdef __GLIBC__ #ifdef __GLIBC__
...@@ -325,7 +327,8 @@ static jboolean ...@@ -325,7 +327,8 @@ static jboolean
ping4(JNIEnv *env, jint fd, struct sockaddr_in* him, jint timeout, ping4(JNIEnv *env, jint fd, struct sockaddr_in* him, jint timeout,
struct sockaddr_in* netif, jint ttl) { struct sockaddr_in* netif, jint ttl) {
jint size; jint size;
jint n, len, hlen1, icmplen; jint n, hlen1, icmplen;
socklen_t len;
char sendbuf[1500]; char sendbuf[1500];
char recvbuf[1500]; char recvbuf[1500];
struct icmp *icmp; struct icmp *icmp;
......
...@@ -196,16 +196,18 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this, ...@@ -196,16 +196,18 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
hints.ai_flags = AI_CANONNAME; hints.ai_flags = AI_CANONNAME;
hints.ai_family = AF_UNSPEC; hints.ai_family = AF_UNSPEC;
#ifdef __solaris__
/* /*
* Workaround for Solaris bug 4160367 - if a hostname contains a * Workaround for Solaris bug 4160367 - if a hostname contains a
* white space then 0.0.0.0 is returned * white space then 0.0.0.0 is returned
*/ */
if (isspace(hostname[0])) { if (isspace((unsigned char)hostname[0])) {
JNU_ThrowByName(env, JNU_JAVANETPKG "UnknownHostException", JNU_ThrowByName(env, JNU_JAVANETPKG "UnknownHostException",
(char *)hostname); (char *)hostname);
JNU_ReleaseStringPlatformChars(env, host, hostname); JNU_ReleaseStringPlatformChars(env, host, hostname);
return NULL; return NULL;
} }
#endif
error = (*getaddrinfo_ptr)(hostname, NULL, &hints, &res); error = (*getaddrinfo_ptr)(hostname, NULL, &hints, &res);
...@@ -455,7 +457,8 @@ static jboolean ...@@ -455,7 +457,8 @@ static jboolean
ping6(JNIEnv *env, jint fd, struct sockaddr_in6* him, jint timeout, ping6(JNIEnv *env, jint fd, struct sockaddr_in6* him, jint timeout,
struct sockaddr_in6* netif, jint ttl) { struct sockaddr_in6* netif, jint ttl) {
jint size; jint size;
jint n, len; jint n;
socklen_t len;
char sendbuf[1500]; char sendbuf[1500];
unsigned char recvbuf[1500]; unsigned char recvbuf[1500];
struct icmp6_hdr *icmp6; struct icmp6_hdr *icmp6;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册