Browse Source

[zebra] Defensive if_getaddrs bug fix.

2006-01-17 Gunnar Stigen <gunnar.stigen@axxessit.no>

	* if_ioctl.c: (if_getaddrs) Be defensive about assuming
	  that struct ifaddrs will have ifa_addr filled in.
paul 15 years ago
parent
commit
61f42aed5e
2 changed files with 9 additions and 0 deletions
  1. 2 0
      zebra/ChangeLog
  2. 7 0
      zebra/if_ioctl.c

+ 2 - 0
zebra/ChangeLog

@@ -2,6 +2,8 @@
 
 	* connected.c: (connected_up_ipv{4,6}) Include interface metric on
 	  connected routes.
+	* if_ioctl.c: (if_getaddrs) Be defensive about assuming
+	  that struct ifaddrs will have ifa_addr filled in.
 
 2006-01-16 Paul Jakma <paul.jakma@sun.com>
 

+ 7 - 0
zebra/if_ioctl.c

@@ -228,6 +228,13 @@ if_getaddrs (void)
 
   for (ifapfree = ifap; ifap; ifap = ifap->ifa_next)
     {
+      if (ifap->ifa_addr == NULL)
+        {
+          zlog_err ("%s: nonsensical ifaddr with NULL ifa_addr, ifname %s",
+                    __func__, (ifap->ifa_name ? ifap->ifa_name : "(null)"));
+          continue;
+        }
+       
       ifp = if_lookup_by_name (ifap->ifa_name);
       if (ifp == NULL)
 	{