From 0422db50ddc70197a244ae182a1bef88d25df3f9 Mon Sep 17 00:00:00 2001 From: ngmr Date: Tue, 22 Nov 2011 09:51:30 +0000 Subject: [PATCH] 7114558: Inet4AddressImpl should use memset (rather than bzero) and NI_MAXHOST (rather than MAXHOSTNAMELEN) Reviewed-by: chegar Contributed-by: Neil Richards --- src/solaris/native/java/net/Inet4AddressImpl.c | 13 ++++++------- src/solaris/native/java/net/Inet6AddressImpl.c | 4 ++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/solaris/native/java/net/Inet4AddressImpl.c b/src/solaris/native/java/net/Inet4AddressImpl.c index 535215295..ea68408ef 100644 --- a/src/solaris/native/java/net/Inet4AddressImpl.c +++ b/src/solaris/native/java/net/Inet4AddressImpl.c @@ -65,11 +65,11 @@ Java_java_net_Inet4AddressImpl_getLocalHostName(JNIEnv *env, jobject this) { /* Something went wrong, maybe networking is not setup? */ strcpy(hostname, "localhost"); } else { - hostname[NI_MAXHOST] = '\0'; - struct addrinfo hints, *res; + struct addrinfo hints, *res; int error; - bzero(&hints, sizeof(hints)); + hostname[NI_MAXHOST] = '\0'; + memset(&hints, 0, sizeof(hints)); hints.ai_flags = AI_CANONNAME; hints.ai_family = AF_INET; @@ -79,7 +79,7 @@ Java_java_net_Inet4AddressImpl_getLocalHostName(JNIEnv *env, jobject this) { getnameinfo(res->ai_addr, res->ai_addrlen, hostname, - MAXHOSTNAMELEN, + NI_MAXHOST, NULL, 0, NI_NAMEREQD); @@ -141,7 +141,7 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this, CHECK_NULL_RETURN(hostname, NULL); /* Try once, with our static buffer. */ - bzero(&hints, sizeof(hints)); + memset(&hints, 0, sizeof(hints)); hints.ai_flags = AI_CANONNAME; hints.ai_family = AF_INET; @@ -261,10 +261,9 @@ Java_java_net_Inet4AddressImpl_getHostByAddr(JNIEnv *env, jobject this, char host[NI_MAXHOST+1]; int error = 0; int len = 0; - jbyte caddr[16]; + jbyte caddr[4]; struct sockaddr_in him4; - struct sockaddr_in6 him6; struct sockaddr *sa; jint addr; diff --git a/src/solaris/native/java/net/Inet6AddressImpl.c b/src/solaris/native/java/net/Inet6AddressImpl.c index 712dece26..4f3f5869c 100644 --- a/src/solaris/native/java/net/Inet6AddressImpl.c +++ b/src/solaris/native/java/net/Inet6AddressImpl.c @@ -85,7 +85,7 @@ Java_java_net_Inet6AddressImpl_getLocalHostName(JNIEnv *env, jobject this) { struct addrinfo hints, *res; int error; - bzero(&hints, sizeof(hints)); + memset(&hints, 0, sizeof(hints)); hints.ai_flags = AI_CANONNAME; hints.ai_family = AF_UNSPEC; @@ -188,7 +188,7 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this, = (*env)->GetStaticBooleanField(env, ia_class, ia_preferIPv6AddressID); /* Try once, with our static buffer. */ - bzero(&hints, sizeof(hints)); + memset(&hints, 0, sizeof(hints)); hints.ai_flags = AI_CANONNAME; hints.ai_family = AF_UNSPEC; -- GitLab