Alistair Leslie-Hughes : dpnet: Add basic validation in IDirectPlay8Peer EnumHosts.
Alexandre Julliard
julliard at winehq.org
Wed Feb 15 16:06:24 CST 2017
Module: wine
Branch: master
Commit: 960b48f4e791c94deddef422e422152e16167e29
URL: http://source.winehq.org/git/wine.git/?a=commit;h=960b48f4e791c94deddef422e422152e16167e29
Author: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date: Wed Feb 15 04:36:15 2017 +0000
dpnet: Add basic validation in IDirectPlay8Peer EnumHosts.
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
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 57f15ef..91a7e3e 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 0c3f9ed..ee2722b 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");
More information about the wine-cvs
mailing list