[TCPIP] Don't assume the TEB is always defined

Fixes the crash in kmtest:TcpIpConnect test.
This commit is contained in:
Pierre Schweitzer 2018-12-31 13:59:58 +01:00
parent ccb8c906b0
commit 89a4cde14a
No known key found for this signature in database
GPG key ID: 7545556C3D585B0B

View file

@ -396,6 +396,7 @@ NTSTATUS FileOpenAddress(
PVOID Options)
{
PADDRESS_FILE AddrFile;
PTEB Teb;
TI_DbgPrint(MID_TRACE, ("Called (Proto %d).\n", Protocol));
@ -429,7 +430,12 @@ NTSTATUS FileOpenAddress(
AddrFile->BCast = 1;
AddrFile->HeaderIncl = 1;
AddrFile->ProcessId = PsGetCurrentProcessId();
AddrFile->SubProcessTag = ((PTEB)PsGetCurrentThreadTeb())->SubProcessTag;
Teb = PsGetCurrentThreadTeb();
if (Teb != NULL) {
AddrFile->SubProcessTag = Teb->SubProcessTag;
}
KeQuerySystemTime(&AddrFile->CreationTime);
/* Make sure address is a local unicast address or 0 */