From 7f3c674aee278de50f796c25c643a5723b5ccd38 Mon Sep 17 00:00:00 2001 From: Peter Hater <7element@mail.bg> Date: Fri, 4 Nov 2016 09:38:21 +0000 Subject: [PATCH] [MSAFD] Disable setting blocking mode if there are WSPAsyncSelect or WSPEventSelect pending calls. CORE-12104 svn path=/trunk/; revision=73120 --- reactos/dll/win32/msafd/misc/dllmain.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/reactos/dll/win32/msafd/misc/dllmain.c b/reactos/dll/win32/msafd/misc/dllmain.c index e2b121b84dd..1a2fef744d2 100644 --- a/reactos/dll/win32/msafd/misc/dllmain.c +++ b/reactos/dll/win32/msafd/misc/dllmain.c @@ -2264,6 +2264,22 @@ WSPIoctl(IN SOCKET Handle, break; } NonBlocking = *((PULONG)lpvInBuffer) ? TRUE : FALSE; + /* Don't allow to go in blocking mode if WSPAsyncSelect or WSPEventSelect is pending */ + if (!NonBlocking) + { + /* If there is an WSPAsyncSelect pending, fail with WSAEINVAL */ + if (Socket->SharedData->AsyncEvents & (~Socket->SharedData->AsyncDisabledEvents)) + { + Errno = WSAEINVAL; + break; + } + /* If there is an WSPEventSelect pending, fail with WSAEINVAL */ + if (Socket->NetworkEvents) + { + Errno = WSAEINVAL; + break; + } + } Socket->SharedData->NonBlocking = NonBlocking ? 1 : 0; NeedsCompletion = FALSE; Errno = SetSocketInformation(Socket, AFD_INFO_BLOCKING_MODE, &NonBlocking, NULL, NULL, lpOverlapped, lpCompletionRoutine);