From: Sebastian Lackner Subject: [2/3] ole32: Verify arguments for CoWaitForMultipleHandles, always initialize index to zero. (resend) Message-Id: <546F1236.7070408@fds-team.de> Date: Fri, 21 Nov 2014 11:21:42 +0100 First mail seems to be lost in transit and doesn't appear on http://source.winehq.org/patches/?! --- dlls/ole32/compobj.c | 11 +++++++++++ dlls/ole32/tests/compobj.c | 13 ------------- 2 files changed, 11 insertions(+), 13 deletions(-) From e0193c3faf069ceeb9ec1f31de1c0291ae57e885 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Wed, 5 Nov 2014 00:39:51 +0100 Subject: ole32: Verify arguments for CoWaitForMultipleHandles, always initialize index to zero. --- dlls/ole32/compobj.c | 11 +++++++++++ dlls/ole32/tests/compobj.c | 13 ------------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c index 1fab04f..1d9b943 100644 --- a/dlls/ole32/compobj.c +++ b/dlls/ole32/compobj.c @@ -4431,6 +4431,17 @@ HRESULT WINAPI CoWaitForMultipleHandles(DWORD dwFlags, DWORD dwTimeout, TRACE("(0x%08x, 0x%08x, %d, %p, %p)\n", dwFlags, dwTimeout, cHandles, pHandles, lpdwindex); + if (!lpdwindex) + return E_INVALIDARG; + + *lpdwindex = 0; + + if (!pHandles) + return E_INVALIDARG; + + if (!cHandles) + return RPC_E_NO_SYNC; + while (TRUE) { DWORD now = GetTickCount(); diff --git a/dlls/ole32/tests/compobj.c b/dlls/ole32/tests/compobj.c index f879773..38b21c9 100644 --- a/dlls/ole32/tests/compobj.c +++ b/dlls/ole32/tests/compobj.c @@ -2139,32 +2139,24 @@ static void test_CoWaitForMultipleHandles(void) PostMessageA(hWnd, WM_DDE_FIRST, 0, 0); hr = CoWaitForMultipleHandles(0, 50, 0, handles, NULL); - todo_wine ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr); success = PeekMessageA(&msg, hWnd, WM_DDE_FIRST, WM_DDE_FIRST, PM_REMOVE); - todo_wine ok(success, "CoWaitForMultipleHandles unexpectedly pumped messages\n"); index = 0xdeadbeef; PostMessageA(hWnd, WM_DDE_FIRST, 0, 0); hr = CoWaitForMultipleHandles(0, 50, 0, NULL, &index); - todo_wine ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr); - todo_wine ok(index == 0, "expected index 0, got %u\n", index); success = PeekMessageA(&msg, hWnd, WM_DDE_FIRST, WM_DDE_FIRST, PM_REMOVE); - todo_wine ok(success, "CoWaitForMultipleHandles unexpectedly pumped messages\n"); index = 0xdeadbeef; PostMessageA(hWnd, WM_DDE_FIRST, 0, 0); hr = CoWaitForMultipleHandles(0, 50, 0, handles, &index); - todo_wine ok(hr == RPC_E_NO_SYNC, "expected RPC_E_NO_SYNC, got 0x%08x\n", hr); - todo_wine ok(index == 0, "expected index 0, got %u\n", index); success = PeekMessageA(&msg, hWnd, WM_DDE_FIRST, WM_DDE_FIRST, PM_REMOVE); - todo_wine ok(success, "CoWaitForMultipleHandles unexpectedly pumped messages\n"); index = 0xdeadbeef; @@ -2187,7 +2179,6 @@ static void test_CoWaitForMultipleHandles(void) PostMessageA(hWnd, WM_DDE_FIRST, 0, 0); hr = CoWaitForMultipleHandles(0, 50, 2, handles, &index); ok(hr == RPC_S_CALLPENDING, "expected RPC_S_CALLPENDING, got 0x%08x\n", hr); - todo_wine ok(index == 0 || broken(index == 0xdeadbeef) /* Win 8 */, "expected index 0, got %u\n", index); success = PeekMessageA(&msg, hWnd, WM_DDE_FIRST, WM_DDE_FIRST, PM_REMOVE); ok(!success, "CoWaitForMultipleHandles didn't pump any messages\n"); @@ -2209,7 +2200,6 @@ static void test_CoWaitForMultipleHandles(void) PostMessageA(hWnd, WM_DDE_FIRST, 0, 0); hr = CoWaitForMultipleHandles(0, 50, 2, handles, &index); ok(hr == RPC_S_CALLPENDING, "expected RPC_S_CALLPENDING, got 0x%08x\n", hr); - todo_wine ok(index == 0 || broken(index == 0xdeadbeef) /* Win 8 */, "expected index 0, got %u\n", index); success = PeekMessageA(&msg, hWnd, WM_DDE_FIRST, WM_DDE_FIRST, PM_REMOVE); ok(!success, "CoWaitForMultipleHandles didn't pump any messages\n"); @@ -2239,7 +2229,6 @@ static void test_CoWaitForMultipleHandles(void) PostMessageA(hWnd, WM_DDE_FIRST, 0, 0); hr = CoWaitForMultipleHandles(COWAIT_ALERTABLE, 50, 2, handles, &index); ok(hr == RPC_S_CALLPENDING, "expected RPC_S_CALLPENDING, got 0x%08x\n", hr); - todo_wine ok(index == 0 || broken(index == 0xdeadbeef) /* Win 8 */, "expected index 0, got %u\n", index); success = PeekMessageA(&msg, hWnd, WM_DDE_FIRST, WM_DDE_FIRST, PM_REMOVE); ok(!success, "CoWaitForMultipleHandles didn't pump any messages\n"); @@ -2263,7 +2252,6 @@ static void test_CoWaitForMultipleHandles(void) ok(success, "PeekMessageA returned FALSE\n"); hr = CoWaitForMultipleHandles(0, 50, 2, handles, &index); ok(hr == RPC_S_CALLPENDING, "expected RPC_S_CALLPENDING, got 0x%08x\n", hr); - todo_wine ok(index == 0 || broken(index == 0xdeadbeef) /* Win 8 */, "expected index 0, got %u\n", index); success = PeekMessageA(&msg, hWnd, WM_DDE_FIRST, WM_DDE_FIRST, PM_REMOVE); ok(!success, "CoWaitForMultipleHandles didn't pump any messages\n"); @@ -2278,7 +2266,6 @@ static void test_CoWaitForMultipleHandles(void) ok(hr == RPC_S_CALLPENDING || broken(hr == E_INVALIDARG) || broken(hr == S_OK) /* Win 8 */, "expected RPC_S_CALLPENDING, got 0x%08x\n", hr); ReleaseSemaphore(handles[1], 1, NULL); - todo_wine ok(index == 0 || broken(index == 1) /* Win 8 */, "expected index 0, got %u\n", index); success = PeekMessageA(&msg, hWnd, WM_DDE_FIRST, WM_DDE_FIRST, PM_REMOVE); ok(!success || broken(success && hr == E_INVALIDARG), -- 2.1.3