--- tcpip.cc.orig       2006-12-08 05:01:19.000000000 +0200
+++ tcpip.cc
@@ -2606,12 +2606,10 @@ int sd;
     ifr = (struct ifreq *) buf;
     if (ifc.ifc_len == 0) 
       fatal("getinterfaces: SIOCGIFCONF claims you have no network 
interfaces!\n");
-#if HAVE_SOCKADDR_SA_LEN
-    /*    len = MAX(sizeof(struct sockaddr), ifr->ifr_addr.sa_len);*/
-    len = ifr->ifr_addr.sa_len + sizeof(ifr->ifr_name);
-#else
     len = sizeof(struct ifreq);
-    /* len = sizeof(SA); */
+#if HAVE_SOCKADDR_SA_LEN
+    if (ifr->ifr_addr.sa_len > sizeof(ifr->ifr_ifru))
+      len += (ifr->ifr_addr.sa_len - sizeof(ifr->ifr_ifru));
 #endif
 
 #if TCPIP_DEBUGGING
@@ -2631,8 +2629,10 @@ int sd;
 
       /* On some platforms (such as FreeBSD), the length of each ifr changes
         based on the sockaddr type used, so we get the next length now */
+      len = sizeof(struct ifreq);
 #if HAVE_SOCKADDR_SA_LEN
-      len = ifr->ifr_addr.sa_len + sizeof(ifr->ifr_name);
+      if (ifr->ifr_addr.sa_len > sizeof(ifr->ifr_ifru))
+        len += (ifr->ifr_addr.sa_len - sizeof(ifr->ifr_ifru));
 #endif 
 
       /* skip any device with no name */

