iphlpapi: Don't crash when enumerating PtP interfaces.

Michael Stefaniuc mstefani at redhat.de
Mon Mar 15 19:09:40 CDT 2010


Point to point interfaces like ppp0, tun0, etc seem to have a NULL
ifaddrs->ifa_addr for the AF_PACKET address family enumeration.

man 3 getifaddrs says in the "CONFORMING TO" section:
  "This means ifa_addr and other fields can actually be NULL..."

---
A modified test program from "man getifaddrs" returns for my box:
lo  address family: 17 (AF_PACKET)
eth0  address family: 17 (AF_PACKET)
pan0  address family: 17 (AF_PACKET)
tun0  address family: <NULL>
lo  address family: 2 (AF_INET)
eth0  address family: 2 (AF_INET)
tun0  address family: 2 (AF_INET)

An easy way to trigger the crash in Wine is to run the Wine Gecko
Installer at WINEPREFIX creation time.



 dlls/iphlpapi/ifenum.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/dlls/iphlpapi/ifenum.c b/dlls/iphlpapi/ifenum.c
index 8653454..5a3db75 100644
--- a/dlls/iphlpapi/ifenum.c
+++ b/dlls/iphlpapi/ifenum.c
@@ -807,7 +807,8 @@ ULONG v6addressesFromIndex(DWORD index, SOCKET_ADDRESS **addrs, ULONG *num_addrs
 
     getInterfaceNameByIndex(index, name);
     for (p = ifa, n = 0; p; p = p->ifa_next)
-      if (p->ifa_addr->sa_family == AF_INET6 && !strcmp(name, p->ifa_name))
+      if (p->ifa_addr && p->ifa_addr->sa_family == AF_INET6 &&
+          !strcmp(name, p->ifa_name))
         n++;
     if (n)
     {
@@ -820,7 +821,8 @@ ULONG v6addressesFromIndex(DWORD index, SOCKET_ADDRESS **addrs, ULONG *num_addrs
 
         for (p = ifa, n = 0; p; p = p->ifa_next)
         {
-          if (p->ifa_addr->sa_family == AF_INET6 && !strcmp(name, p->ifa_name))
+          if (p->ifa_addr && p->ifa_addr->sa_family == AF_INET6 &&
+              !strcmp(name, p->ifa_name))
           {
             struct sockaddr_in6 *addr = (struct sockaddr_in6 *)p->ifa_addr;
 
-- 
1.7.0.2



More information about the wine-patches mailing list