Author: cgutman
Date: Mon Jun 7 03:50:26 2010
New Revision: 47652
URL:
http://svn.reactos.org/svn/reactos?rev=47652&view=rev
Log:
[MSAFD]
- Fix 2 more callers who don't pass a valid lpErrno pointer
- Check the return value of WSPSocket
- Return WSAEWOULDBLOCK if there are no connections that can be accepted instead of
silently returning 0 which is not INVALID_SOCKET so the caller treats it as a valid socket
pointer and passes it to other functions which caused wide-spread mayhem since we never
checked whether the socket handle the caller passed was valid until my last commit
Modified:
trunk/reactos/dll/win32/msafd/misc/dllmain.c
trunk/reactos/dll/win32/msafd/misc/sndrcv.c
Modified: trunk/reactos/dll/win32/msafd/misc/dllmain.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msafd/misc/dllma…
==============================================================================
--- trunk/reactos/dll/win32/msafd/misc/dllmain.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/msafd/misc/dllmain.c [iso-8859-1] Mon Jun 7 03:50:26 2010
@@ -1102,12 +1102,17 @@
Timeout.tv_sec=0;
Timeout.tv_usec=0;
- WSPSelect(0, &ReadSet, NULL, NULL, &Timeout, NULL);
+ if (WSPSelect(0, &ReadSet, NULL, NULL, &Timeout, lpErrno) == SOCKET_ERROR)
+ {
+ NtClose(SockEvent);
+ return INVALID_SOCKET;
+ }
if (ReadSet.fd_array[0] != Socket->Handle)
{
NtClose(SockEvent);
- return 0;
+ *lpErrno = WSAEWOULDBLOCK;
+ return INVALID_SOCKET;
}
/* Send IOCTL */
@@ -1345,7 +1350,9 @@
&ProtocolInfo,
GroupID,
Socket->SharedData.CreateFlags,
- NULL);
+ lpErrno);
+ if (AcceptSocket == INVALID_SOCKET)
+ return INVALID_SOCKET;
/* Set up the Accept Structure */
AcceptData.ListenHandle = (HANDLE)AcceptSocket;
Modified: trunk/reactos/dll/win32/msafd/misc/sndrcv.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msafd/misc/sndrc…
==============================================================================
--- trunk/reactos/dll/win32/msafd/misc/sndrcv.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/msafd/misc/sndrcv.c [iso-8859-1] Mon Jun 7 03:50:26 2010
@@ -51,7 +51,11 @@
/* Deactive WSPEventSelect */
if (Socket->SharedData.AsyncEvents)
{
- WSPEventSelect(Handle, NULL, 0, NULL);
+ if (WSPEventSelect(Handle, NULL, 0, lpErrno) == SOCKET_ERROR)
+ {
+ HeapFree(GetProcessHeap(), 0, AsyncData);
+ return SOCKET_ERROR;
+ }
}
/* Create the Asynch Thread if Needed */