Author: cgutman
Date: Sat Aug 23 20:53:58 2008
New Revision: 35584
URL:
http://svn.reactos.org/svn/reactos?rev=35584&view=rev
Log:
- Merge aicom-network-fixes up to r35583
Modified:
trunk/reactos/drivers/network/afd/afd/bind.c
trunk/reactos/drivers/network/afd/afd/connect.c
trunk/reactos/drivers/network/afd/afd/listen.c
trunk/reactos/drivers/network/afd/afd/lock.c
Modified: trunk/reactos/drivers/network/afd/afd/bind.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/bi…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/bind.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/afd/bind.c [iso-8859-1] Sat Aug 23 20:53:58 2008
@@ -70,6 +70,8 @@
TdiBuildConnectionInfo( &FCB->AddressFrom,
FCB->LocalAddress );
+ if( !FCB->AddressFrom ) return UnlockAndMaybeComplete( FCB, STATUS_NO_MEMORY, Irp, 0,
NULL );
+
AFD_DbgPrint(MID_TRACE,("Calling TdiReceiveDatagram\n"));
Status = TdiReceiveDatagram
Modified: trunk/reactos/drivers/network/afd/afd/connect.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/co…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/connect.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/afd/connect.c [iso-8859-1] Sat Aug 23 20:53:58 2008
@@ -33,7 +33,6 @@
}
NTSTATUS MakeSocketIntoConnection( PAFD_FCB FCB ) {
- NTSTATUS Status;
/* Allocate the receive area and start receiving */
FCB->Recv.Window =
@@ -51,16 +50,14 @@
FCB->State = SOCKET_STATE_CONNECTED;
- Status = TdiReceive( &FCB->ReceiveIrp.InFlightRequest,
- FCB->Connection.Object,
- TDI_RECEIVE_NORMAL,
- FCB->Recv.Window,
- FCB->Recv.Size,
- &FCB->ReceiveIrp.Iosb,
- ReceiveComplete,
- FCB );
-
- return Status;
+ return TdiReceive( &FCB->ReceiveIrp.InFlightRequest,
+ FCB->Connection.Object,
+ TDI_RECEIVE_NORMAL,
+ FCB->Recv.Window,
+ FCB->Recv.Size,
+ &FCB->ReceiveIrp.Iosb,
+ ReceiveComplete,
+ FCB );
}
static NTSTATUS NTAPI StreamSocketConnectComplete
@@ -84,15 +81,15 @@
if( NT_SUCCESS(Irp->IoStatus.Status) ) {
FCB->PollState |= AFD_EVENT_CONNECT | AFD_EVENT_SEND;
+ AFD_DbgPrint(MID_TRACE,("Going to connected state %d\n", FCB->State));
FCB->State = SOCKET_STATE_CONNECTED;
- AFD_DbgPrint(MID_TRACE,("Going to connected state %d\n", FCB->State));
- PollReeval( FCB->DeviceExt, FCB->FileObject );
} else {
FCB->PollState |= AFD_EVENT_CONNECT_FAIL | AFD_EVENT_RECEIVE;
AFD_DbgPrint(MID_TRACE,("Going to bound state\n"));
FCB->State = SOCKET_STATE_BOUND;
- PollReeval( FCB->DeviceExt, FCB->FileObject );
- }
+ }
+
+ PollReeval( FCB->DeviceExt, FCB->FileObject );
/* Succeed pending irps on the FUNCTION_CONNECT list */
while( !IsListEmpty( &FCB->PendingIrpList[FUNCTION_CONNECT] ) ) {
@@ -199,6 +196,11 @@
FCB->RemoteAddress =
TaCopyTransportAddress( &ConnectReq->RemoteAddress );
+ if( !FCB->RemoteAddress ) {
+ Status = STATUS_NO_MEMORY;
+ break;
+ }
+
if( FCB->Flags & AFD_ENDPOINT_CONNECTIONLESS )
{
Status = STATUS_SUCCESS;
Modified: trunk/reactos/drivers/network/afd/afd/listen.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/li…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/listen.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/afd/listen.c [iso-8859-1] Sat Aug 23 20:53:58 2008
@@ -61,6 +61,13 @@
IPAddr = (PTA_IP_ADDRESS)&ListenReceive->Address;
+ if( !IPAddr ) {
+ if( Irp->MdlAddress ) UnlockRequest( Irp, IoGetCurrentIrpStackLocation( Irp ) );
+ Irp->IoStatus.Status = STATUS_NO_MEMORY;
+ Irp->IoStatus.Information = 0;
+ IoCompleteRequest( Irp, IO_NETWORK_INCREMENT );
+ }
+
AFD_DbgPrint(MID_TRACE,("IPAddr->TAAddressCount %d\n",
IPAddr->TAAddressCount));
AFD_DbgPrint(MID_TRACE,("IPAddr->Address[0].AddressType %d\n",
@@ -172,7 +179,7 @@
0, NULL );
if( FCB->State != SOCKET_STATE_BOUND ) {
- Status = STATUS_UNSUCCESSFUL;
+ Status = STATUS_INVALID_PARAMETER;
AFD_DbgPrint(MID_TRACE,("Could not listen an unbound socket\n"));
return UnlockAndMaybeComplete( FCB, Status, Irp, 0, NULL );
}
Modified: trunk/reactos/drivers/network/afd/afd/lock.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/lo…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/lock.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/afd/lock.c [iso-8859-1] Sat Aug 23 20:53:58 2008
@@ -130,9 +130,13 @@
if( LockFailed ) {
IoFreeMdl( MapBuf[i].Mdl );
MapBuf[i].Mdl = NULL;
- LockFailed = FALSE;
+ ExFreePool( NewBuf );
+ return NULL;
}
- }
+ } else {
+ ExFreePool( NewBuf );
+ return NULL;
+ }
}
}
@@ -164,7 +168,7 @@
* pointers. This will allow the system to do proper alerting */
PAFD_HANDLE LockHandles( PAFD_HANDLE HandleArray, UINT HandleCount ) {
UINT i;
- NTSTATUS Status;
+ NTSTATUS Status = STATUS_SUCCESS;
PAFD_HANDLE FileObjects = ExAllocatePool
( NonPagedPool, HandleCount * sizeof(AFD_HANDLE) );
@@ -173,13 +177,21 @@
HandleArray[i].Status = 0;
HandleArray[i].Events = HandleArray[i].Events;
FileObjects[i].Handle = 0;
- Status = ObReferenceObjectByHandle
- ( (PVOID)HandleArray[i].Handle,
- FILE_ALL_ACCESS,
- NULL,
- KernelMode,
- (PVOID*)&FileObjects[i].Handle,
- NULL );
+ if( !HandleArray[i].Handle ) continue;
+ if( NT_SUCCESS(Status) ) {
+ Status = ObReferenceObjectByHandle
+ ( (PVOID)HandleArray[i].Handle,
+ FILE_ALL_ACCESS,
+ NULL,
+ KernelMode,
+ (PVOID*)&FileObjects[i].Handle,
+ NULL );
+ }
+ }
+
+ if( !NT_SUCCESS(Status) ) {
+ UnlockHandles( FileObjects, HandleCount );
+ return NULL;
}
return FileObjects;
@@ -312,12 +324,14 @@
}
VOID SocketCalloutEnter( PAFD_FCB FCB ) {
+ ASSERT(!FCB->Critical);
ASSERT(FCB->Locked);
FCB->Critical = TRUE;
SocketStateUnlock( FCB );
}
VOID SocketCalloutLeave( PAFD_FCB FCB ) {
+ ASSERT(FCB->Critical);
FCB->Critical = FALSE;
SocketAcquireStateLock( FCB );
}