Browse Source

getaddrinfo: runp->ifa_addr indeed can be NULL, don't dereference it
ifaddrs.c: cosmetics, no code changes

Denis Vlasenko 16 years ago
parent
commit
c40b05b4c4
2 changed files with 3 additions and 4 deletions
  1. 2 0
      libc/inet/getaddrinfo.c
  2. 1 4
      libc/inet/ifaddrs.c

+ 2 - 0
libc/inet/getaddrinfo.c

@@ -189,6 +189,8 @@ static unsigned __check_pf(void)
 	}
 
 	for (runp = ifa; runp != NULL; runp = runp->ifa_next) {
+		if (runp->ifa_addr == NULL)
+			continue;
 #if defined __UCLIBC_HAS_IPV4__
 		if (runp->ifa_addr->sa_family == PF_INET)
 			seen |= SEEN_IPV4;

+ 1 - 4
libc/inet/ifaddrs.c

@@ -452,10 +452,7 @@ getifaddrs (struct ifaddrs **ifap)
 
   /* Allocate memory for all entries we have and initialize next
      pointer.  */
-  ifas = (struct ifaddrs_storage *) calloc (1,
-					    (newlink + newaddr)
-					    * sizeof (struct ifaddrs_storage)
-					    + ifa_data_size);
+  ifas = calloc (1, (newlink + newaddr) * sizeof (ifas[0]) + ifa_data_size);
   if (ifas == NULL)
     {
       result = -1;