[PATCH 2/3] dpnet: Add basic validation in IDirectPlay8Peer EnumHosts

Alistair Leslie-Hughes leslie_alistair at hotmail.com
Tue Feb 14 22:36:15 CST 2017


Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
---
 dlls/dpnet/peer.c         | 15 +++++++++++++--
 dlls/dpnet/tests/client.c |  8 ++++----
 2 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/dlls/dpnet/peer.c b/dlls/dpnet/peer.c
index 57f15efc6a..91a7e3e217 100644
--- a/dlls/dpnet/peer.c
+++ b/dlls/dpnet/peer.c
@@ -457,11 +457,22 @@ static HRESULT WINAPI IDirectPlay8PeerImpl_EnumHosts(IDirectPlay8Peer *iface,
         const DWORD dwUserEnumDataSize, const DWORD dwEnumCount, const DWORD dwRetryInterval,
         const DWORD dwTimeOut, void * const pvUserContext, DPNHANDLE * const pAsyncHandle, const DWORD dwFlags)
 {
+    IDirectPlay8PeerImpl* This = impl_from_IDirectPlay8Peer(iface);
+
     FIXME("(%p)->(%p,%p,%p,%p,%x,%x,%x,%x,%p,%p,%x): stub\n",
-            iface, pApplicationDesc, pAddrHost, pDeviceInfo, pUserEnumData, dwUserEnumDataSize, dwEnumCount,
+            This, pApplicationDesc, pAddrHost, pDeviceInfo, pUserEnumData, dwUserEnumDataSize, dwEnumCount,
             dwRetryInterval, dwTimeOut, pvUserContext, pAsyncHandle, dwFlags);
 
-    return DPNERR_GENERIC;
+    if(!This->msghandler)
+        return DPNERR_UNINITIALIZED;
+
+    if((dwFlags & DPNENUMHOSTS_SYNC) && pAsyncHandle)
+        return DPNERR_INVALIDPARAM;
+
+    if(dwUserEnumDataSize > This->spcaps.dwMaxEnumPayloadSize)
+        return DPNERR_ENUMQUERYTOOLARGE;
+
+    return (dwFlags & DPNENUMHOSTS_SYNC) ? DPN_OK : DPNSUCCESS_PENDING;
 }
 
 static HRESULT WINAPI IDirectPlay8PeerImpl_DestroyPeer(IDirectPlay8Peer *iface, const DPNID dpnidClient,
diff --git a/dlls/dpnet/tests/client.c b/dlls/dpnet/tests/client.c
index 0c3f9ed3ce..ee2722b523 100644
--- a/dlls/dpnet/tests/client.c
+++ b/dlls/dpnet/tests/client.c
@@ -609,7 +609,7 @@ static void test_enum_hosts_peer(void)
     ok(hr == S_OK, "IDirectPlay8Address failed with 0x%08x\n", hr);
 
     hr = IDirectPlay8Peer_EnumHosts(peer, &appdesc, host, local, NULL, 0, INFINITE, 0, INFINITE, NULL,  &async, 0);
-    todo_wine ok(hr == DPNSUCCESS_PENDING, "IDirectPlay8Peer_EnumServiceProviders failed with 0x%08x\n", hr);
+    ok(hr == DPNSUCCESS_PENDING, "IDirectPlay8Peer_EnumServiceProviders failed with 0x%08x\n", hr);
     todo_wine ok(async, "No Handle returned\n");
 
     hr = IDirectPlay8Peer_CancelAsyncOperation(peer, async, 0);
@@ -617,15 +617,15 @@ static void test_enum_hosts_peer(void)
 
     /* No Initialize has been called on peer2. */
     hr = IDirectPlay8Peer_EnumHosts(peer2, &appdesc, host, local, NULL, 0, INFINITE, 0, INFINITE, NULL,  &async, 0);
-    todo_wine ok(hr == DPNERR_UNINITIALIZED, "IDirectPlay8Peer_EnumHosts failed with 0x%08x\n", hr);
+    ok(hr == DPNERR_UNINITIALIZED, "IDirectPlay8Peer_EnumHosts failed with 0x%08x\n", hr);
 
     /* Since we are running asynchronously, EnumHosts returns DPNSUCCESS_PENDING. */
     hr = IDirectPlay8Peer_EnumHosts(peer, &appdesc, host, local, NULL, 0, INFINITE, 0, INFINITE, NULL,  &async, 0);
-    todo_wine ok(hr == DPNSUCCESS_PENDING, "IDirectPlay8Peer_EnumHosts failed with 0x%08x\n", hr);
+    ok(hr == DPNSUCCESS_PENDING, "IDirectPlay8Peer_EnumHosts failed with 0x%08x\n", hr);
     todo_wine ok(async, "No Handle returned\n");
 
     hr = IDirectPlay8Peer_EnumHosts(peer, &appdesc, host, local, NULL, 0, INFINITE, 0, INFINITE, NULL,  &async2, 0);
-    todo_wine ok(hr == DPNSUCCESS_PENDING, "IDirectPlay8Peer_EnumHosts failed with 0x%08x\n", hr);
+    ok(hr == DPNSUCCESS_PENDING, "IDirectPlay8Peer_EnumHosts failed with 0x%08x\n", hr);
     todo_wine ok(async2, "No Handle returned\n");
     todo_wine ok(async2 != async, "Same handle returned.\n");
 
-- 
2.11.0




More information about the wine-patches mailing list