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

Reviewed-by: alanb
This commit is contained in:
Christos Zoulas 2009-02-11 13:16:53 +00:00 committed by Chris Hegarty
parent 9aab9d4aeb
commit 68c4bef974
2 changed files with 10 additions and 4 deletions

View File

@ -165,16 +165,18 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
hostname = JNU_GetStringPlatformChars(env, host, JNI_FALSE);
CHECK_NULL_RETURN(hostname, NULL);
#ifdef __solaris__
/*
* Workaround for Solaris bug 4160367 - if a hostname contains a
* 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",
(char *)hostname);
JNU_ReleaseStringPlatformChars(env, host, hostname);
return NULL;
}
#endif
/* Try once, with our static buffer. */
#ifdef __GLIBC__
@ -325,7 +327,8 @@ static jboolean
ping4(JNIEnv *env, jint fd, struct sockaddr_in* him, jint timeout,
struct sockaddr_in* netif, jint ttl) {
jint size;
jint n, len, hlen1, icmplen;
jint n, hlen1, icmplen;
socklen_t len;
char sendbuf[1500];
char recvbuf[1500];
struct icmp *icmp;

View File

@ -196,16 +196,18 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
hints.ai_flags = AI_CANONNAME;
hints.ai_family = AF_UNSPEC;
#ifdef __solaris__
/*
* Workaround for Solaris bug 4160367 - if a hostname contains a
* 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",
(char *)hostname);
JNU_ReleaseStringPlatformChars(env, host, hostname);
return NULL;
}
#endif
error = (*getaddrinfo_ptr)(hostname, NULL, &hints, &res);
@ -455,7 +457,8 @@ static jboolean
ping6(JNIEnv *env, jint fd, struct sockaddr_in6* him, jint timeout,
struct sockaddr_in6* netif, jint ttl) {
jint size;
jint n, len;
jint n;
socklen_t len;
char sendbuf[1500];
unsigned char recvbuf[1500];
struct icmp6_hdr *icmp6;