Browse Source

resolv: fix bug in res_init with ipv6 nameservers

Thanks to Christian Krause <chkr plauener.de> for finding and fixing
this!

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Bernhard Reutner-Fischer 13 years ago
parent
commit
e8dc8eca8d
1 changed files with 2 additions and 2 deletions
  1. 2 2
      libc/inet/resolv.c

+ 2 - 2
libc/inet/resolv.c

@@ -2964,7 +2964,7 @@ int res_init(void)
 		if (__nameserver[i].sa.sa_family == AF_INET6
 		 && m < ARRAY_SIZE(rp->_u._ext.nsaddrs)
 		) {
-			struct sockaddr_in6 *sa6 = malloc(sizeof(sa6));
+			struct sockaddr_in6 *sa6 = malloc(sizeof(*sa6));
 			if (sa6) {
 				*sa6 = __nameserver[i].sa6; /* struct copy */
 				rp->_u._ext.nsaddrs[m] = sa6;
@@ -2981,7 +2981,7 @@ int res_init(void)
 
 #else /* IPv6 only */
 	while (m < ARRAY_SIZE(rp->_u._ext.nsaddrs) && i < __nameservers) {
-		struct sockaddr_in6 *sa6 = malloc(sizeof(sa6));
+		struct sockaddr_in6 *sa6 = malloc(sizeof(*sa6));
 		if (sa6) {
 			*sa6 = __nameserver[i].sa6; /* struct copy */
 			rp->_u._ext.nsaddrs[m] = sa6;