[PATCH] iphlpapi: Return gateway address 0.0.0.0/255.255.255.255 from GetAdaptersInfo if it's not set.

Hans Leidekker hans at codeweavers.com
Thu Jul 2 03:23:27 CDT 2020


Signed-off-by: Hans Leidekker <hans at codeweavers.com>
---
 dlls/iphlpapi/iphlpapi_main.c  | 2 ++
 dlls/iphlpapi/tests/iphlpapi.c | 9 ++++++---
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/dlls/iphlpapi/iphlpapi_main.c b/dlls/iphlpapi/iphlpapi_main.c
index ff9d0d3a53..c039086229 100644
--- a/dlls/iphlpapi/iphlpapi_main.c
+++ b/dlls/iphlpapi/iphlpapi_main.c
@@ -742,6 +742,8 @@ DWORD WINAPI GetAdaptersInfo(PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen)
               }
               /* Find first router through this interface, which we'll assume
                * is the default gateway for this adapter */
+              strcpy(ptr->GatewayList.IpAddress.String, "0.0.0.0");
+              strcpy(ptr->GatewayList.IpMask.String, "255.255.255.255");
               for (i = 0; i < routeTable->dwNumEntries; i++)
                 if (routeTable->table[i].dwForwardIfIndex == ptr->Index
                  && routeTable->table[i].u1.ForwardType ==
diff --git a/dlls/iphlpapi/tests/iphlpapi.c b/dlls/iphlpapi/tests/iphlpapi.c
index d5690c11ee..6965ae8457 100644
--- a/dlls/iphlpapi/tests/iphlpapi.c
+++ b/dlls/iphlpapi/tests/iphlpapi.c
@@ -1120,10 +1120,13 @@ static void testGetAdaptersInfo(void)
            apiReturn);
         ptr = buf;
         while (ptr) {
-            ok(ptr->IpAddressList.IpAddress.String[0], "A valid IP must be present\n");
+            ok(ptr->IpAddressList.IpAddress.String[0], "A valid IP address must be present\n");
             ok(ptr->IpAddressList.IpMask.String[0], "A valid mask must be present\n");
-            trace("Adapter '%s', IP %s, Mask %s\n", ptr->AdapterName,
-                  ptr->IpAddressList.IpAddress.String, ptr->IpAddressList.IpMask.String);
+            ok(ptr->GatewayList.IpAddress.String[0], "A valid IP address must be present\n");
+            ok(ptr->GatewayList.IpMask.String[0], "A valid mask must be present\n");
+            trace("adapter '%s', address %s/%s gateway %s/%s\n", ptr->AdapterName,
+                  ptr->IpAddressList.IpAddress.String, ptr->IpAddressList.IpMask.String,
+                  ptr->GatewayList.IpAddress.String, ptr->GatewayList.IpMask.String);
             ptr = ptr->Next;
         }
         HeapFree(GetProcessHeap(), 0, buf);
-- 
2.20.1




More information about the wine-devel mailing list