[MSAFD]
[reactos.git] / reactos / dll / win32 / msafd / misc / sndrcv.c
index 57f9569..db26a36 100644 (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 );
@@ -209,9 +219,6 @@ WSPRecv(SOCKET Handle,
     /* Return the Flags */
     *ReceiveFlags = 0;
 
-    if (Status == STATUS_PENDING)
-        return MsafdReturnWithErrno(Status, lpErrno, IOSB->Information, lpNumberOfBytesRead);
-
     switch (Status)
     {
         case STATUS_RECEIVE_EXPEDITED:
@@ -264,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 );
@@ -359,9 +371,6 @@ WSPRecvFrom(SOCKET Handle,
     /* Return the Flags */
     *ReceiveFlags = 0;
 
-    if (Status == STATUS_PENDING)
-        return MsafdReturnWithErrno(Status, lpErrno, IOSB->Information, lpNumberOfBytesRead);
-
     switch (Status)
     {
         case STATUS_RECEIVE_EXPEDITED: *ReceiveFlags = MSG_OOB;
@@ -405,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 );
@@ -529,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)