[TCPIP] Check for allocation failures in ReadIpConfiguration. CID 1411924

This commit is contained in:
Thomas Faber 2018-01-08 13:51:04 +01:00
parent 63a3a2cbb8
commit d87786bf6c
No known key found for this signature in database
GPG key ID: 076E7C3D44720826

View file

@ -637,14 +637,16 @@ BOOLEAN ReadIpConfiguration(PIP_INTERFACE Interface)
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
RegistryDataU.Length = KeyValueInfo->DataLength; RegistryDataU.Length = KeyValueInfo->DataLength;
RtlUnicodeStringToAnsiString(&RegistryDataA, Status = RtlUnicodeStringToAnsiString(&RegistryDataA,
&RegistryDataU, &RegistryDataU,
TRUE); TRUE);
if (NT_SUCCESS(Status))
AddrInitIPv4(&Interface->Unicast, inet_addr(RegistryDataA.Buffer)); {
AddrInitIPv4(&Interface->Unicast,
RtlFreeAnsiString(&RegistryDataA); inet_addr(RegistryDataA.Buffer));
RtlFreeAnsiString(&RegistryDataA);
}
} }
Status = ZwQueryValueKey(ParameterHandle, Status = ZwQueryValueKey(ParameterHandle,
@ -656,16 +658,18 @@ BOOLEAN ReadIpConfiguration(PIP_INTERFACE Interface)
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
RegistryDataU.Length = KeyValueInfo->DataLength; RegistryDataU.Length = KeyValueInfo->DataLength;
RtlUnicodeStringToAnsiString(&RegistryDataA, Status = RtlUnicodeStringToAnsiString(&RegistryDataA,
&RegistryDataU, &RegistryDataU,
TRUE); TRUE);
if (NT_SUCCESS(Status))
AddrInitIPv4(&Interface->Netmask, inet_addr(RegistryDataA.Buffer)); {
AddrInitIPv4(&Interface->Netmask,
RtlFreeAnsiString(&RegistryDataA); inet_addr(RegistryDataA.Buffer));
RtlFreeAnsiString(&RegistryDataA);
}
} }
/* We have to wait until both IP address and subnet mask /* We have to wait until both IP address and subnet mask
* are read to add the interface route, but we must do it * are read to add the interface route, but we must do it
* before we add the default gateway */ * before we add the default gateway */
@ -683,24 +687,26 @@ BOOLEAN ReadIpConfiguration(PIP_INTERFACE Interface)
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
RegistryDataU.Length = KeyValueInfo->DataLength; RegistryDataU.Length = KeyValueInfo->DataLength;
RtlUnicodeStringToAnsiString(&RegistryDataA, Status = RtlUnicodeStringToAnsiString(&RegistryDataA,
&RegistryDataU, &RegistryDataU,
TRUE); TRUE);
if (NT_SUCCESS(Status))
AddrInitIPv4(&Router, inet_addr(RegistryDataA.Buffer)); {
AddrInitIPv4(&Router, inet_addr(RegistryDataA.Buffer));
if (!AddrIsUnspecified(&Router))
RouterCreateRoute(&DefaultMask, &DefaultMask, &Router, Interface, 1); if (!AddrIsUnspecified(&Router))
RouterCreateRoute(&DefaultMask, &DefaultMask, &Router, Interface, 1);
RtlFreeAnsiString(&RegistryDataA);
RtlFreeAnsiString(&RegistryDataA);
}
} }
} }
ExFreePoolWithTag(KeyValueInfo, KEY_VALUE_TAG); ExFreePoolWithTag(KeyValueInfo, KEY_VALUE_TAG);
ZwClose(ParameterHandle); ZwClose(ParameterHandle);
} }
return TRUE; return TRUE;
} }