mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 10:22:59 +00:00
[0.4.13][IP][TCPIP][LWIP] Backports 2023-08-13 (also fixes a BSOD)
0.4.15-dev-6399-gf8a6542b15
[IP] Don't reference uninitialized PCB to avoid BSOD. CORE-18982 0.4.15-dev-6395-g2010a5b8d9
[IP] Unlock Connection when TCPAllocatePort() fails. CORE-18371 0.4.15-dev-5707-g874d317a71
[IP] Allow 0xFFFF as Valid Network Port Number (#5074) CORE-18371 CORE-18764 PARTIALLY pick 0.4.14-dev-1326-g792b64ea46
[TCPIP][FORMATTING] Format TiDispatch function. No functional changes (#2112) and strip some EOL-whitespace. Just to make sure that the binary sizes did not increase: tcpip.sys master GCC8.4.0dbg RosBEWin2.2.2 462.848 tcpip.sys 0.4.14 GCC4.7.2dbg RosBEWin2.1.6 425.984 -> 425.984 tcpip.sys 0.4.13 GCC4.7.2dbg RosBEWin2.1.6 417.792 -> 417.792 tcpip.sys 0.4.12 GCC4.7.2dbg RosBEWin2.1.6 421.888 -> 421.888 tcpip.sys 0.4.11 GCC4.7.2dbg RosBEWin2.1.6 421.888 -> 421.888 tcpip.sys 0.4.10 GCC4.7.2dbg RosBEWin2.1.6 413.696 -> 413.696 tcpip.sys 0.4. 9 GCC4.7.2dbg RosBEWin2.1.6 413.696 -> 413.696 tcpip.sys 0.4. 8 GCC4.7.2dbg RosBEWin2.1.6 413.696 -> 413.696 tcpip.sys 0.4. 7 GCC4.7.2dbg RosBEWin2.1.6 413.696 -> 413.696
This commit is contained in:
parent
4a6b865483
commit
b743b450cd
10 changed files with 130 additions and 112 deletions
|
@ -396,6 +396,7 @@ NTSTATUS FileOpenAddress(
|
||||||
PVOID Options)
|
PVOID Options)
|
||||||
{
|
{
|
||||||
PADDRESS_FILE AddrFile;
|
PADDRESS_FILE AddrFile;
|
||||||
|
UINT AllocatedPort;
|
||||||
|
|
||||||
TI_DbgPrint(MID_TRACE, ("Called (Proto %d).\n", Protocol));
|
TI_DbgPrint(MID_TRACE, ("Called (Proto %d).\n", Protocol));
|
||||||
|
|
||||||
|
@ -464,14 +465,15 @@ NTSTATUS FileOpenAddress(
|
||||||
if (Address->Address[0].Address[0].sin_port)
|
if (Address->Address[0].Address[0].sin_port)
|
||||||
{
|
{
|
||||||
/* The client specified an explicit port so we force a bind to this */
|
/* The client specified an explicit port so we force a bind to this */
|
||||||
AddrFile->Port = TCPAllocatePort(Address->Address[0].Address[0].sin_port);
|
AllocatedPort = TCPAllocatePort(Address->Address[0].Address[0].sin_port);
|
||||||
|
|
||||||
/* Check for bind success */
|
/* Check for bind success */
|
||||||
if (AddrFile->Port == 0xffff)
|
if (AllocatedPort == (UINT)-1)
|
||||||
{
|
{
|
||||||
ExFreePoolWithTag(AddrFile, ADDR_FILE_TAG);
|
ExFreePoolWithTag(AddrFile, ADDR_FILE_TAG);
|
||||||
return STATUS_ADDRESS_ALREADY_EXISTS;
|
return STATUS_ADDRESS_ALREADY_EXISTS;
|
||||||
}
|
}
|
||||||
|
AddrFile->Port = AllocatedPort;
|
||||||
|
|
||||||
/* Sanity check */
|
/* Sanity check */
|
||||||
ASSERT(Address->Address[0].Address[0].sin_port == AddrFile->Port);
|
ASSERT(Address->Address[0].Address[0].sin_port == AddrFile->Port);
|
||||||
|
@ -479,14 +481,15 @@ NTSTATUS FileOpenAddress(
|
||||||
else if (!AddrIsUnspecified(&AddrFile->Address))
|
else if (!AddrIsUnspecified(&AddrFile->Address))
|
||||||
{
|
{
|
||||||
/* The client is trying to bind to a local address so allocate a port now too */
|
/* The client is trying to bind to a local address so allocate a port now too */
|
||||||
AddrFile->Port = TCPAllocatePort(0);
|
AllocatedPort = TCPAllocatePort(0);
|
||||||
|
|
||||||
/* Check for bind success */
|
/* Check for bind success */
|
||||||
if (AddrFile->Port == 0xffff)
|
if (AllocatedPort == (UINT)-1)
|
||||||
{
|
{
|
||||||
ExFreePoolWithTag(AddrFile, ADDR_FILE_TAG);
|
ExFreePoolWithTag(AddrFile, ADDR_FILE_TAG);
|
||||||
return STATUS_ADDRESS_ALREADY_EXISTS;
|
return STATUS_ADDRESS_ALREADY_EXISTS;
|
||||||
}
|
}
|
||||||
|
AddrFile->Port = AllocatedPort;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -501,16 +504,16 @@ NTSTATUS FileOpenAddress(
|
||||||
|
|
||||||
case IPPROTO_UDP:
|
case IPPROTO_UDP:
|
||||||
TI_DbgPrint(MID_TRACE,("Allocating udp port\n"));
|
TI_DbgPrint(MID_TRACE,("Allocating udp port\n"));
|
||||||
AddrFile->Port =
|
AllocatedPort = UDPAllocatePort(Address->Address[0].Address[0].sin_port);
|
||||||
UDPAllocatePort(Address->Address[0].Address[0].sin_port);
|
|
||||||
|
|
||||||
if ((Address->Address[0].Address[0].sin_port &&
|
if ((Address->Address[0].Address[0].sin_port &&
|
||||||
AddrFile->Port != Address->Address[0].Address[0].sin_port) ||
|
AllocatedPort != Address->Address[0].Address[0].sin_port) ||
|
||||||
AddrFile->Port == 0xffff)
|
AllocatedPort == (UINT)-1)
|
||||||
{
|
{
|
||||||
ExFreePoolWithTag(AddrFile, ADDR_FILE_TAG);
|
ExFreePoolWithTag(AddrFile, ADDR_FILE_TAG);
|
||||||
return STATUS_ADDRESS_ALREADY_EXISTS;
|
return STATUS_ADDRESS_ALREADY_EXISTS;
|
||||||
}
|
}
|
||||||
|
AddrFile->Port = AllocatedPort;
|
||||||
|
|
||||||
TI_DbgPrint(MID_TRACE,("Setting port %d (wanted %d)\n",
|
TI_DbgPrint(MID_TRACE,("Setting port %d (wanted %d)\n",
|
||||||
AddrFile->Port,
|
AddrFile->Port,
|
||||||
|
|
|
@ -473,10 +473,6 @@ TiDispatchInternal(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS NTAPI
|
|
||||||
TiDispatch(
|
|
||||||
PDEVICE_OBJECT DeviceObject,
|
|
||||||
PIRP Irp)
|
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Dispatch routine for IRP_MJ_DEVICE_CONTROL requests
|
* FUNCTION: Dispatch routine for IRP_MJ_DEVICE_CONTROL requests
|
||||||
* ARGUMENTS:
|
* ARGUMENTS:
|
||||||
|
@ -485,11 +481,15 @@ TiDispatch(
|
||||||
* RETURNS:
|
* RETURNS:
|
||||||
* Status of the operation
|
* Status of the operation
|
||||||
*/
|
*/
|
||||||
|
NTSTATUS NTAPI
|
||||||
|
TiDispatch(
|
||||||
|
PDEVICE_OBJECT DeviceObject,
|
||||||
|
PIRP Irp)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PIO_STACK_LOCATION IrpSp;
|
PIO_STACK_LOCATION IrpSp;
|
||||||
|
|
||||||
IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
||||||
|
|
||||||
TI_DbgPrint(DEBUG_IRP, ("[TCPIP, TiDispatch] Called. IRP is at (0x%X).\n", Irp));
|
TI_DbgPrint(DEBUG_IRP, ("[TCPIP, TiDispatch] Called. IRP is at (0x%X).\n", Irp));
|
||||||
|
|
||||||
|
@ -541,7 +541,7 @@ TiDispatch(
|
||||||
|
|
||||||
TI_DbgPrint(DEBUG_IRP, ("[TCPIP, TiDispatch] Leaving. Status = (0x%X).\n", Status));
|
TI_DbgPrint(DEBUG_IRP, ("[TCPIP, TiDispatch] Leaving. Status = (0x%X).\n", Status));
|
||||||
|
|
||||||
return IRPFinish( Irp, Status );
|
return IRPFinish(Irp, Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -78,10 +78,14 @@ NTSTATUS TCPListen(PCONNECTION_ENDPOINT Connection, UINT Backlog)
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
/* Allocate the port in the port bitmap */
|
/* Allocate the port in the port bitmap */
|
||||||
Connection->AddressFile->Port = TCPAllocatePort(LocalAddress.Address[0].Address[0].sin_port);
|
UINT AllocatedPort = TCPAllocatePort(LocalAddress.Address[0].Address[0].sin_port);
|
||||||
|
/* This should never fail unless all ports are in use */
|
||||||
/* This should never fail */
|
if (AllocatedPort == (UINT) -1)
|
||||||
ASSERT(Connection->AddressFile->Port != 0xFFFF);
|
{
|
||||||
|
UnlockObject(Connection, OldIrql);
|
||||||
|
return STATUS_TOO_MANY_ADDRESSES;
|
||||||
|
}
|
||||||
|
Connection->AddressFile->Port = AllocatedPort;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,7 +189,7 @@ NTSTATUS TCPStartup(VOID)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
Status = PortsStartup( &TCPPorts, 1, 0xfffe );
|
Status = PortsStartup(&TCPPorts, 1, 0xffff);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
return Status;
|
return Status;
|
||||||
|
@ -342,15 +342,21 @@ NTSTATUS TCPConnect
|
||||||
/* Check if we had an unspecified port */
|
/* Check if we had an unspecified port */
|
||||||
if (!Connection->AddressFile->Port)
|
if (!Connection->AddressFile->Port)
|
||||||
{
|
{
|
||||||
|
UINT AllocatedPort;
|
||||||
|
|
||||||
/* We did, so we need to copy back the port */
|
/* We did, so we need to copy back the port */
|
||||||
Status = TCPGetSockAddress(Connection, (PTRANSPORT_ADDRESS)&LocalAddress, FALSE);
|
Status = TCPGetSockAddress(Connection, (PTRANSPORT_ADDRESS)&LocalAddress, FALSE);
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
/* Allocate the port in the port bitmap */
|
/* Allocate the port in the port bitmap */
|
||||||
Connection->AddressFile->Port = TCPAllocatePort(LocalAddress.Address[0].Address[0].sin_port);
|
AllocatedPort = TCPAllocatePort(LocalAddress.Address[0].Address[0].sin_port);
|
||||||
|
/* This should never fail unless all ports are in use */
|
||||||
/* This should never fail */
|
if (AllocatedPort == (UINT) -1)
|
||||||
ASSERT(Connection->AddressFile->Port != 0xFFFF);
|
{
|
||||||
|
UnlockObject(Connection, OldIrql);;
|
||||||
|
return STATUS_TOO_MANY_ADDRESSES;
|
||||||
|
}
|
||||||
|
Connection->AddressFile->Port = AllocatedPort;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -373,6 +379,11 @@ NTSTATUS TCPConnect
|
||||||
Status = TCPTranslateError(LibTCPConnect(Connection,
|
Status = TCPTranslateError(LibTCPConnect(Connection,
|
||||||
&connaddr,
|
&connaddr,
|
||||||
RemotePort));
|
RemotePort));
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
RemoveEntryList(&Bucket->Entry);
|
||||||
|
ExFreeToNPagedLookasideList(&TdiBucketLookasideList, Bucket);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue