iphlpapi: Return error for IP address with value zero in IcmpSendEcho

Bruno Jesus 00cpxxx at gmail.com
Thu Jan 9 16:45:37 CST 2014


I missed the function name in the subject. Please ignore 101595.

Fixes http://bugs.winehq.org/show_bug.cgi?id=33272
-------------- next part --------------
diff --git a/dlls/iphlpapi/icmp.c b/dlls/iphlpapi/icmp.c
index 7d84811..2a29ffb 100644
--- a/dlls/iphlpapi/icmp.c
+++ b/dlls/iphlpapi/icmp.c
@@ -239,6 +239,12 @@ DWORD WINAPI IcmpSendEcho(
     }
     /* check the request size against SO_MAX_MSG_SIZE using getsockopt */
 
+    if (!DestinationAddress) {
+        /* IP_BAD_DESTINATION in win <= 2003 */
+        SetLastError(ERROR_INVALID_NETNAME);
+        return 0;
+    }
+
     /* Prepare the request */
     id=getpid() & 0xFFFF;
     seq=InterlockedIncrement(&icmp_sequence) & 0xFFFF;
diff --git a/dlls/iphlpapi/tests/iphlpapi.c b/dlls/iphlpapi/tests/iphlpapi.c
index 94716d7..13a21c0 100644
--- a/dlls/iphlpapi/tests/iphlpapi.c
+++ b/dlls/iphlpapi/tests/iphlpapi.c
@@ -906,12 +906,10 @@ todo_wine
     SetLastError(0xdeadbeef);
     ret = pIcmpSendEcho(icmp, address, senddata, sizeof(senddata), NULL, replydata, replysz, 1000);
     error = GetLastError();
-    todo_wine {
     ok (!ret, "IcmpSendEcho succeeded unexpectedly\n");
     ok (error == ERROR_INVALID_NETNAME
         || broken(error == IP_BAD_DESTINATION) /* <= 2003 */,
         "expected 1214, got %d\n", error);
-    }
 
     address = htonl(INADDR_LOOPBACK);
     if (0) /* crashes in XP */


More information about the wine-patches mailing list