7114558: Inet4AddressImpl should use memset (rather than bzero) and NI_MAXHOST (rather than MAXHOSTNAMELEN)
Reviewed-by: chegar
Contributed-by: Neil Richards <neil.richards@ngmr.net>
--- a/jdk/src/solaris/native/java/net/Inet4AddressImpl.c Fri Nov 11 14:40:18 2011 +0000
+++ b/jdk/src/solaris/native/java/net/Inet4AddressImpl.c Tue Nov 22 09:51:30 2011 +0000
@@ -65,11 +65,11 @@
/* 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 @@
getnameinfo(res->ai_addr,
res->ai_addrlen,
hostname,
- MAXHOSTNAMELEN,
+ NI_MAXHOST,
NULL,
0,
NI_NAMEREQD);
@@ -141,7 +141,7 @@
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 @@
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;
--- a/jdk/src/solaris/native/java/net/Inet6AddressImpl.c Fri Nov 11 14:40:18 2011 +0000
+++ b/jdk/src/solaris/native/java/net/Inet6AddressImpl.c Tue Nov 22 09:51:30 2011 +0000
@@ -85,7 +85,7 @@
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 @@
= (*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;