[0.4.13][IP][TCPIP][LWIP] Backports 2023-08-13 (also fixes a BSOD)

0.4.15-dev-6399-g f8a6542b15 [IP] Don't reference uninitialized PCB to avoid BSOD. CORE-18982
0.4.15-dev-6395-g 2010a5b8d9 [IP] Unlock Connection when TCPAllocatePort() fails. CORE-18371
0.4.15-dev-5707-g 874d317a71 [IP] Allow 0xFFFF as Valid Network Port Number (#5074) CORE-18371 CORE-18764
PARTIALLY pick 0.4.14-dev-1326-g 792b64ea46 [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:
Joachim Henze 2023-08-13 16:25:31 +02:00
parent 4a6b865483
commit b743b450cd
10 changed files with 130 additions and 112 deletions

View file

@ -189,7 +189,7 @@ NTSTATUS TCPStartup(VOID)
{
NTSTATUS Status;
Status = PortsStartup( &TCPPorts, 1, 0xfffe );
Status = PortsStartup(&TCPPorts, 1, 0xffff);
if (!NT_SUCCESS(Status))
{
return Status;
@ -342,15 +342,21 @@ NTSTATUS TCPConnect
/* Check if we had an unspecified port */
if (!Connection->AddressFile->Port)
{
UINT AllocatedPort;
/* We did, so we need to copy back the port */
Status = TCPGetSockAddress(Connection, (PTRANSPORT_ADDRESS)&LocalAddress, FALSE);
if (NT_SUCCESS(Status))
{
/* Allocate the port in the port bitmap */
Connection->AddressFile->Port = TCPAllocatePort(LocalAddress.Address[0].Address[0].sin_port);
/* This should never fail */
ASSERT(Connection->AddressFile->Port != 0xFFFF);
AllocatedPort = TCPAllocatePort(LocalAddress.Address[0].Address[0].sin_port);
/* This should never fail unless all ports are in use */
if (AllocatedPort == (UINT) -1)
{
UnlockObject(Connection, OldIrql);;
return STATUS_TOO_MANY_ADDRESSES;
}
Connection->AddressFile->Port = AllocatedPort;
}
}
@ -373,6 +379,11 @@ NTSTATUS TCPConnect
Status = TCPTranslateError(LibTCPConnect(Connection,
&connaddr,
RemotePort));
if (!NT_SUCCESS(Status))
{
RemoveEntryList(&Bucket->Entry);
ExFreeToNPagedLookasideList(&TdiBucketLookasideList, Bucket);
}
}
}