- Validate that we found the corresponding socket information in our socket information list
- Fixes a crash in Firefox 2 when it tries to call accept() with a closed socket

svn path=/trunk/; revision=47650
This commit is contained in:
Cameron Gutman
2010-06-07 01:24:15 +00:00
parent ad1721c016
commit 88c29ff4f2
3 changed files with 89 additions and 0 deletions
+52
View File
@@ -440,6 +440,12 @@ WSPCloseSocket(IN SOCKET Handle,
/* Get the Socket Structure associate to this Socket*/
Socket = GetSocketStructure(Handle);
if (!Socket)
{
NtClose(SockEvent);
*lpErrno = WSAENOTSOCK;
return SOCKET_ERROR;
}
if (Socket->HelperEvents & WSH_NOTIFY_CLOSE)
{
@@ -635,6 +641,12 @@ WSPBind(SOCKET Handle,
/* Get the Socket Structure associate to this Socket*/
Socket = GetSocketStructure(Handle);
if (!Socket)
{
HeapFree(GlobalHeap, 0, BindData);
*lpErrno = WSAENOTSOCK;
return SOCKET_ERROR;
}
/* Set up Address in TDI Format */
BindData->Address.TAAddressCount = 1;
@@ -728,6 +740,11 @@ WSPListen(SOCKET Handle,
/* Get the Socket Structure associate to this Socket*/
Socket = GetSocketStructure(Handle);
if (!Socket)
{
*lpErrno = WSAENOTSOCK;
return SOCKET_ERROR;
}
if (Socket->SharedData.Listening)
return 0;
@@ -1072,6 +1089,12 @@ WSPAccept(SOCKET Handle,
/* Get the Socket Structure associate to this Socket*/
Socket = GetSocketStructure(Handle);
if (!Socket)
{
NtClose(SockEvent);
*lpErrno = WSAENOTSOCK;
return INVALID_SOCKET;
}
/* If this is non-blocking, make sure there's something for us to accept */
FD_ZERO(&ReadSet);
@@ -1428,6 +1451,12 @@ WSPConnect(SOCKET Handle,
/* Get the Socket Structure associate to this Socket*/
Socket = GetSocketStructure(Handle);
if (!Socket)
{
NtClose(SockEvent);
*lpErrno = WSAENOTSOCK;
return SOCKET_ERROR;
}
/* Bind us First */
if (Socket->SharedData.State == SocketOpen)
@@ -1644,6 +1673,12 @@ WSPShutdown(SOCKET Handle,
/* Get the Socket Structure associate to this Socket*/
Socket = GetSocketStructure(Handle);
if (!Socket)
{
NtClose(SockEvent);
*lpErrno = WSAENOTSOCK;
return SOCKET_ERROR;
}
/* Set AFD Disconnect Type */
switch (HowTo)
@@ -1718,6 +1753,12 @@ WSPGetSockName(IN SOCKET Handle,
/* Get the Socket Structure associate to this Socket*/
Socket = GetSocketStructure(Handle);
if (!Socket)
{
NtClose(SockEvent);
*lpErrno = WSAENOTSOCK;
return SOCKET_ERROR;
}
/* Allocate a buffer for the address */
TdiAddressSize =
@@ -1806,6 +1847,12 @@ WSPGetPeerName(IN SOCKET s,
/* Get the Socket Structure associate to this Socket*/
Socket = GetSocketStructure(s);
if (!Socket)
{
NtClose(SockEvent);
*lpErrno = WSAENOTSOCK;
return SOCKET_ERROR;
}
/* Allocate a buffer for the address */
TdiAddressSize = sizeof(TRANSPORT_ADDRESS) + *NameLength;
@@ -1883,6 +1930,11 @@ WSPIoctl(IN SOCKET Handle,
/* Get the Socket Structure associate to this Socket*/
Socket = GetSocketStructure(Handle);
if (!Socket)
{
*lpErrno = WSAENOTSOCK;
return SOCKET_ERROR;
}
switch( dwIoControlCode )
{
+12
View File
@@ -36,6 +36,12 @@ WSPEventSelect(
/* Get the Socket Structure associate to this Socket*/
Socket = GetSocketStructure(Handle);
if (!Socket)
{
NtClose(SockEvent);
*lpErrno = WSAENOTSOCK;
return SOCKET_ERROR;
}
/* Set Socket to Non-Blocking */
BlockMode = 1;
@@ -152,6 +158,12 @@ WSPEnumNetworkEvents(
/* Get the Socket Structure associate to this Socket*/
Socket = GetSocketStructure(Handle);
if (!Socket)
{
NtClose(SockEvent);
*lpErrno = WSAENOTSOCK;
return SOCKET_ERROR;
}
EnumReq.Event = hEventObject;
+25
View File
@@ -29,6 +29,11 @@ WSPAsyncSelect(IN SOCKET Handle,
/* Get the Socket Structure associated to this Socket */
Socket = GetSocketStructure(Handle);
if (!Socket)
{
*lpErrno = WSAENOTSOCK;
return SOCKET_ERROR;
}
/* Allocate the Async Data Structure to pass on to the Thread later */
AsyncData = HeapAlloc(GetProcessHeap(), 0, sizeof(*AsyncData));
@@ -111,6 +116,11 @@ WSPRecv(SOCKET Handle,
/* Get the Socket Structure associate to this Socket*/
Socket = GetSocketStructure(Handle);
if (!Socket)
{
*lpErrno = WSAENOTSOCK;
return SOCKET_ERROR;
}
Status = NtCreateEvent( &SockEvent, GENERIC_READ | GENERIC_WRITE,
NULL, 1, FALSE );
@@ -261,6 +271,11 @@ WSPRecvFrom(SOCKET Handle,
/* Get the Socket Structure associate to this Socket*/
Socket = GetSocketStructure(Handle);
if (!Socket)
{
*lpErrno = WSAENOTSOCK;
return SOCKET_ERROR;
}
Status = NtCreateEvent( &SockEvent, GENERIC_READ | GENERIC_WRITE,
NULL, 1, FALSE );
@@ -399,6 +414,11 @@ WSPSend(SOCKET Handle,
/* Get the Socket Structure associate to this Socket*/
Socket = GetSocketStructure(Handle);
if (!Socket)
{
*lpErrno = WSAENOTSOCK;
return SOCKET_ERROR;
}
Status = NtCreateEvent( &SockEvent, GENERIC_READ | GENERIC_WRITE,
NULL, 1, FALSE );
@@ -523,6 +543,11 @@ WSPSendTo(SOCKET Handle,
/* Get the Socket Structure associate to this Socket */
Socket = GetSocketStructure(Handle);
if (!Socket)
{
*lpErrno = WSAENOTSOCK;
return SOCKET_ERROR;
}
/* Bind us First */
if (Socket->SharedData.State == SocketOpen)