diff --git a/reactos/drivers/network/tcpip/tcpip/fileobjs.c b/reactos/drivers/network/tcpip/tcpip/fileobjs.c index 6d9b0b5507b..f7ead95d6cc 100644 --- a/reactos/drivers/network/tcpip/tcpip/fileobjs.c +++ b/reactos/drivers/network/tcpip/tcpip/fileobjs.c @@ -295,9 +295,21 @@ NTSTATUS FileOpenAddress( /* Sanity check */ ASSERT(Address->Address[0].Address[0].sin_port == AddrFile->Port); } + else if (!AddrIsUnspecified(&AddrFile->Address)) + { + /* The client is trying to bind to a local address so allocate a port now too */ + AddrFile->Port = TCPAllocatePort(0); + + /* Check for bind success */ + if (AddrFile->Port == 0xffff) + { + ExFreePoolWithTag(AddrFile, ADDR_FILE_TAG); + return STATUS_ADDRESS_ALREADY_EXISTS; + } + } else { - /* The client wants an unspecified port so we wait to see what the TCP library gives us */ + /* The client wants an unspecified port with an unspecified address so we wait to see what the TCP library gives us */ AddrFile->Port = 0; }