[ros-diffs] [cgutman] 45400: [AFD] - Add more cases to TdiAddressSizeFromType - Return STATUS_INVALID_PARAMETER instead of bugchecking if somebody gives us a bad address type - Fixes Steam (confirmed by Geoz) - Will also be merged to trunk soon

cgutman at svn.reactos.org cgutman at svn.reactos.org
Wed Feb 3 21:02:39 CET 2010


Author: cgutman
Date: Wed Feb  3 21:02:39 2010
New Revision: 45400

URL: http://svn.reactos.org/svn/reactos?rev=45400&view=rev
Log:
[AFD]
 - Add more cases to TdiAddressSizeFromType
 - Return STATUS_INVALID_PARAMETER instead of bugchecking if somebody gives us a bad address type
 - Fixes Steam (confirmed by Geoz)
 - Will also be merged to trunk soon

Modified:
    branches/aicom-network-branch/drivers/network/afd/afd/bind.c
    branches/aicom-network-branch/drivers/network/afd/afd/connect.c
    branches/aicom-network-branch/drivers/network/afd/afd/listen.c
    branches/aicom-network-branch/drivers/network/afd/afd/main.c
    branches/aicom-network-branch/drivers/network/afd/afd/tdiconn.c
    branches/aicom-network-branch/drivers/network/afd/afd/write.c

Modified: branches/aicom-network-branch/drivers/network/afd/afd/bind.c
URL: http://svn.reactos.org/svn/reactos/branches/aicom-network-branch/drivers/network/afd/afd/bind.c?rev=45400&r1=45399&r2=45400&view=diff
==============================================================================
--- branches/aicom-network-branch/drivers/network/afd/afd/bind.c [iso-8859-1] (original)
+++ branches/aicom-network-branch/drivers/network/afd/afd/bind.c [iso-8859-1] Wed Feb  3 21:02:39 2010
@@ -71,14 +71,15 @@
     FCB->LocalAddress = TaCopyTransportAddress( &BindReq->Address );
 
     if( FCB->LocalAddress )
-	TdiBuildConnectionInfo( &FCB->AddressFrom,
-				FCB->LocalAddress );
+	Status = TdiBuildConnectionInfo( &FCB->AddressFrom,
+					 FCB->LocalAddress );
 
-    if( FCB->AddressFrom )
+    if( NT_SUCCESS(Status) )
 	Status = WarmSocketForBind( FCB );
-    else return UnlockAndMaybeComplete(FCB, STATUS_NO_MEMORY, Irp, 0);
+    AFD_DbgPrint(MID_TRACE,("FCB->Flags %x\n", FCB->Flags));
 
-    AFD_DbgPrint(MID_TRACE,("FCB->Flags %x\n", FCB->Flags));
+    if( !NT_SUCCESS(Status) )
+        return UnlockAndMaybeComplete(FCB, Status, Irp, 0);
 
     if( FCB->Flags & AFD_ENDPOINT_CONNECTIONLESS ) {
 	AFD_DbgPrint(MID_TRACE,("Calling TdiReceiveDatagram\n"));

Modified: branches/aicom-network-branch/drivers/network/afd/afd/connect.c
URL: http://svn.reactos.org/svn/reactos/branches/aicom-network-branch/drivers/network/afd/afd/connect.c?rev=45400&r1=45399&r2=45400&view=diff
==============================================================================
--- branches/aicom-network-branch/drivers/network/afd/afd/connect.c [iso-8859-1] (original)
+++ branches/aicom-network-branch/drivers/network/afd/afd/connect.c [iso-8859-1] Wed Feb  3 21:02:39 2010
@@ -423,16 +423,17 @@
 	if( !NT_SUCCESS(Status) )
 	    break;
 
-	TdiBuildConnectionInfo
+	Status = TdiBuildConnectionInfo
 	    ( &FCB->ConnectInfo,
 	      &ConnectReq->RemoteAddress );
 
-        if( FCB->ConnectInfo )
-            TdiBuildConnectionInfo(&TargetAddress,
-                                   &ConnectReq->RemoteAddress);
-
-
-	if( TargetAddress ) {
+        if( NT_SUCCESS(Status) )
+            Status = TdiBuildConnectionInfo(&TargetAddress,
+                                  	    &ConnectReq->RemoteAddress);
+        else break;
+
+
+	if( NT_SUCCESS(Status) ) {
             TargetAddress->UserData = FCB->ConnectData;
             TargetAddress->UserDataLength = FCB->ConnectDataSize;
             TargetAddress->Options = FCB->ConnectOptions;
@@ -454,7 +455,7 @@
                 FCB->State = SOCKET_STATE_CONNECTING;
 		return LeaveIrpUntilLater( FCB, Irp, FUNCTION_CONNECT );
             }
-	} else Status = STATUS_NO_MEMORY;
+	}
 	break;
 
     default:

Modified: branches/aicom-network-branch/drivers/network/afd/afd/listen.c
URL: http://svn.reactos.org/svn/reactos/branches/aicom-network-branch/drivers/network/afd/afd/listen.c?rev=45400&r1=45399&r2=45400&view=diff
==============================================================================
--- branches/aicom-network-branch/drivers/network/afd/afd/listen.c [iso-8859-1] (original)
+++ branches/aicom-network-branch/drivers/network/afd/afd/listen.c [iso-8859-1] Wed Feb  3 21:02:39 2010
@@ -156,13 +156,13 @@
                                 FCB->ListenIrp.
                                 ConnectionReturnInfo->RemoteAddress));
 
-        TdiBuildNullConnectionInfo( &Qelt->ConnInfo, AddressType );
-        if( Qelt->ConnInfo ) {
+        Status = TdiBuildNullConnectionInfo( &Qelt->ConnInfo, AddressType );
+        if( NT_SUCCESS(Status) ) {
             TaCopyTransportAddressInPlace
                ( Qelt->ConnInfo->RemoteAddress,
                  FCB->ListenIrp.ConnectionReturnInfo->RemoteAddress );
             InsertTailList( &FCB->PendingConnections, &Qelt->ListEntry );
-        } else Status = STATUS_NO_MEMORY;
+        }
     }
 
     /* Satisfy a pre-accept request if one is available */
@@ -235,28 +235,21 @@
 
     if( !NT_SUCCESS(Status) ) return UnlockAndMaybeComplete( FCB, Status, Irp, 0 );
 
-    TdiBuildNullConnectionInfo
+    Status = TdiBuildNullConnectionInfo
 	( &FCB->ListenIrp.ConnectionCallInfo,
 	  FCB->LocalAddress->Address[0].AddressType );
-    TdiBuildNullConnectionInfo
+
+    if (!NT_SUCCESS(Status)) return UnlockAndMaybeComplete(FCB, Status, Irp, 0);
+
+    Status = TdiBuildNullConnectionInfo
 	( &FCB->ListenIrp.ConnectionReturnInfo,
 	  FCB->LocalAddress->Address[0].AddressType );
 
-    if( !FCB->ListenIrp.ConnectionReturnInfo || !FCB->ListenIrp.ConnectionCallInfo )
+    if (!NT_SUCCESS(Status))
     {
-        if (FCB->ListenIrp.ConnectionReturnInfo)
-        {
-            ExFreePool(FCB->ListenIrp.ConnectionReturnInfo);
-            FCB->ListenIrp.ConnectionReturnInfo = NULL;
-        }
-
-        if (FCB->ListenIrp.ConnectionCallInfo)
-        {
-            ExFreePool(FCB->ListenIrp.ConnectionCallInfo);
-            FCB->ListenIrp.ConnectionCallInfo = NULL;
-        }
-
-	return UnlockAndMaybeComplete( FCB, STATUS_NO_MEMORY, Irp, 0 );
+        ExFreePool(FCB->ListenIrp.ConnectionCallInfo);
+        FCB->ListenIrp.ConnectionCallInfo = NULL;
+        return UnlockAndMaybeComplete(FCB, Status, Irp, 0);
     }
 
     FCB->State = SOCKET_STATE_LISTENING;
@@ -337,29 +330,22 @@
 	Status = WarmSocketForConnection( FCB );
 
 	if( Status == STATUS_SUCCESS ) {
-            TdiBuildNullConnectionInfo
-	      ( &FCB->ListenIrp.ConnectionCallInfo,
-	        FCB->LocalAddress->Address[0].AddressType );
-            TdiBuildNullConnectionInfo
-	      ( &FCB->ListenIrp.ConnectionReturnInfo,
-                FCB->LocalAddress->Address[0].AddressType );
-
-            if( !FCB->ListenIrp.ConnectionReturnInfo || !FCB->ListenIrp.ConnectionCallInfo )
-            {
-                if (FCB->ListenIrp.ConnectionReturnInfo)
-                {
-                    ExFreePool(FCB->ListenIrp.ConnectionReturnInfo);
-                    FCB->ListenIrp.ConnectionReturnInfo = NULL;
-                }
-
-                if (FCB->ListenIrp.ConnectionCallInfo)
-                {
-                    ExFreePool(FCB->ListenIrp.ConnectionCallInfo);
-                    FCB->ListenIrp.ConnectionCallInfo = NULL;
-                }
-
-	        return UnlockAndMaybeComplete( FCB, STATUS_NO_MEMORY, Irp, 0 );
-            }
+	     Status = TdiBuildNullConnectionInfo
+		( &FCB->ListenIrp.ConnectionCallInfo,
+		  FCB->LocalAddress->Address[0].AddressType );
+
+	    if (!NT_SUCCESS(Status)) return UnlockAndMaybeComplete(FCB, Status, Irp, 0);
+
+	    Status = TdiBuildNullConnectionInfo
+		( &FCB->ListenIrp.ConnectionReturnInfo,
+		  FCB->LocalAddress->Address[0].AddressType );
+
+	    if (!NT_SUCCESS(Status))
+	    {
+	        ExFreePool(FCB->ListenIrp.ConnectionCallInfo);
+	        FCB->ListenIrp.ConnectionCallInfo = NULL;
+	        return UnlockAndMaybeComplete(FCB, Status, Irp, 0);
+	    }
 
 	    Status = TdiListen( &FCB->ListenIrp.InFlightRequest,
 				FCB->Connection.Object,

Modified: branches/aicom-network-branch/drivers/network/afd/afd/main.c
URL: http://svn.reactos.org/svn/reactos/branches/aicom-network-branch/drivers/network/afd/afd/main.c?rev=45400&r1=45399&r2=45400&view=diff
==============================================================================
--- branches/aicom-network-branch/drivers/network/afd/afd/main.c [iso-8859-1] (original)
+++ branches/aicom-network-branch/drivers/network/afd/afd/main.c [iso-8859-1] Wed Feb  3 21:02:39 2010
@@ -498,7 +498,7 @@
 	       ( &ConnectionReturnInfo, FCB->RemoteAddress->Address[0].AddressType );
 
         if( !NT_SUCCESS(Status) )
-	    return UnlockAndMaybeComplete( FCB, STATUS_NO_MEMORY,
+	    return UnlockAndMaybeComplete( FCB, Status,
 				           Irp, 0 );
 
         if( DisReq->DisconnectType & AFD_DISCONNECT_SEND )

Modified: branches/aicom-network-branch/drivers/network/afd/afd/tdiconn.c
URL: http://svn.reactos.org/svn/reactos/branches/aicom-network-branch/drivers/network/afd/afd/tdiconn.c?rev=45400&r1=45399&r2=45400&view=diff
==============================================================================
--- branches/aicom-network-branch/drivers/network/afd/afd/tdiconn.c [iso-8859-1] (original)
+++ branches/aicom-network-branch/drivers/network/afd/afd/tdiconn.c [iso-8859-1] Wed Feb  3 21:02:39 2010
@@ -14,13 +14,21 @@
 
 UINT TdiAddressSizeFromType( UINT AddressType ) {
     switch( AddressType ) {
-    case AF_INET:
+    case TDI_ADDRESS_TYPE_IP:
 		return sizeof(TA_IP_ADDRESS);
+    case TDI_ADDRESS_TYPE_APPLETALK:
+		return sizeof(TA_APPLETALK_ADDRESS);
+    case TDI_ADDRESS_TYPE_NETBIOS:
+		return sizeof(TA_NETBIOS_ADDRESS);
+    /* case TDI_ADDRESS_TYPE_NS: */
+    case TDI_ADDRESS_TYPE_IPX:
+		return sizeof(TA_IPX_ADDRESS);
+    case TDI_ADDRESS_TYPE_VNS:
+		return sizeof(TA_VNS_ADDRESS);
     default:
-		AFD_DbgPrint(MID_TRACE,("TdiAddressSizeFromType - invalid type: %x\n", AddressType));
-		KeBugCheck( 0 );
+		DbgPrint("TdiAddressSizeFromType - invalid type: %x\n", AddressType);
+		return 0;
     }
-    return 0;
 }
 
 UINT TaLengthOfAddress( PTA_ADDRESS Addr ) {
@@ -85,6 +93,8 @@
 	PTRANSPORT_ADDRESS TransportAddress;
 
 	TdiAddressSize = TdiAddressSizeFromType(Type);
+	if (!TdiAddressSize)
+		return STATUS_INVALID_PARAMETER;
 
 	RtlZeroMemory(ConnInfo,
 				  sizeof(TDI_CONNECTION_INFORMATION) +
@@ -118,6 +128,10 @@
 	NTSTATUS Status;
 
 	TdiAddressSize = TdiAddressSizeFromType(Type);
+	if (!TdiAddressSize) {
+		*ConnectionInfo = NULL;
+		return STATUS_INVALID_PARAMETER;
+	}
 
 	ConnInfo = (PTDI_CONNECTION_INFORMATION)
 		ExAllocatePool(NonPagedPool,
@@ -199,6 +213,9 @@
 
     /* FIXME: Get from socket information */
     TdiAddressSize = TdiAddressSizeFromType(From->Address[0].AddressType);
+	if (!TdiAddressSize)
+		return STATUS_INVALID_PARAMETER;
+
     SizeOfEntry = TdiAddressSize + sizeof(TDI_CONNECTION_INFORMATION);
 
     LayoutFrame = (PCHAR)ExAllocatePool(NonPagedPool, 2 * SizeOfEntry);

Modified: branches/aicom-network-branch/drivers/network/afd/afd/write.c
URL: http://svn.reactos.org/svn/reactos/branches/aicom-network-branch/drivers/network/afd/afd/write.c?rev=45400&r1=45399&r2=45400&view=diff
==============================================================================
--- branches/aicom-network-branch/drivers/network/afd/afd/write.c [iso-8859-1] (original)
+++ branches/aicom-network-branch/drivers/network/afd/afd/write.c [iso-8859-1] Wed Feb  3 21:02:39 2010
@@ -247,9 +247,9 @@
                                            Irp, 0 );
 		}
 
-        TdiBuildConnectionInfo( &TargetAddress, FCB->RemoteAddress );
-
-		if( TargetAddress ) {
+        Status = TdiBuildConnectionInfo( &TargetAddress, FCB->RemoteAddress );
+
+		if( NT_SUCCESS(Status) ) {
             Status = TdiSendDatagram
                 ( &FCB->SendIrp.InFlightRequest,
                   FCB->AddressFile.Object,
@@ -261,7 +261,7 @@
                   FCB );
 
 			ExFreePool( TargetAddress );
-		} else Status = STATUS_NO_MEMORY;
+		}
 
         if( Status == STATUS_PENDING ) Status = STATUS_SUCCESS;
 
@@ -419,12 +419,12 @@
 					((PTRANSPORT_ADDRESS)SendReq->TdiConnection.RemoteAddress)->
 					Address[0].AddressType));
 
-    TdiBuildConnectionInfo( &TargetAddress,
+    Status = TdiBuildConnectionInfo( &TargetAddress,
 							((PTRANSPORT_ADDRESS)SendReq->TdiConnection.RemoteAddress) );
 
     /* Check the size of the Address given ... */
 
-    if( TargetAddress ) {
+    if( NT_SUCCESS(Status) ) {
 		Status = TdiSendDatagram
 			( &FCB->SendIrp.InFlightRequest,
 			  FCB->AddressFile.Object,
@@ -436,7 +436,7 @@
 			  FCB );
 
 		ExFreePool( TargetAddress );
-    } else Status = STATUS_NO_MEMORY;
+    }
 
     if( Status == STATUS_PENDING ) Status = STATUS_SUCCESS;
 




More information about the Ros-diffs mailing list