NetworkPkg:Fix NULL pointer dereference issues.

Revise some errors that some Null pointers may be dereferenced.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo <lubo.zhang@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18961 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Zhang Lubo
2015-11-26 08:17:46 +00:00
committed by luobozhang
parent 8e496a7abc
commit 1b96428d92
3 changed files with 41 additions and 32 deletions

View File

@@ -40,6 +40,7 @@ EFI_HTTP_PROTOCOL mEfiHttpTemplate = {
This is NULL.
HttpConfigData is NULL.
HttpConfigData->AccessPoint is NULL.
@retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources.
@retval EFI_NOT_STARTED The HTTP instance is not configured.
**/
@@ -71,6 +72,9 @@ EfiHttpGetModeData (
if (HttpInstance->LocalAddressIsIPv6) {
Http6AccessPoint = AllocateZeroPool (sizeof (EFI_HTTPv6_ACCESS_POINT));
if (Http6AccessPoint == NULL) {
return EFI_OUT_OF_RESOURCES;
}
CopyMem (
Http6AccessPoint,
&HttpInstance->Ipv6Node,
@@ -79,6 +83,9 @@ EfiHttpGetModeData (
HttpConfigData->AccessPoint.IPv6Node = Http6AccessPoint;
} else {
Http4AccessPoint = AllocateZeroPool (sizeof (EFI_HTTPv4_ACCESS_POINT));
if (Http4AccessPoint == NULL) {
return EFI_OUT_OF_RESOURCES;
}
CopyMem (
Http4AccessPoint,
&HttpInstance->IPv4Node,
@@ -885,6 +892,8 @@ HttpResponseWorker (
goto Error;
}
ASSERT (HttpHeaders != NULL);
//
// Cache the part of body.
//
@@ -1287,14 +1296,19 @@ EfiHttpPoll (
HttpInstance = HTTP_INSTANCE_FROM_PROTOCOL (This);
ASSERT (HttpInstance != NULL);
if (HttpInstance->State != HTTP_STATE_TCP_CONNECTED || (HttpInstance->Tcp4 == NULL &&
HttpInstance->Tcp6 == NULL)) {
if (HttpInstance->State != HTTP_STATE_TCP_CONNECTED) {
return EFI_NOT_STARTED;
}
if (HttpInstance->LocalAddressIsIPv6) {
if (HttpInstance->Tcp6 == NULL) {
return EFI_NOT_STARTED;
}
Status = HttpInstance->Tcp6->Poll (HttpInstance->Tcp6);
} else {
if (HttpInstance->Tcp4 == NULL) {
return EFI_NOT_STARTED;
}
Status = HttpInstance->Tcp4->Poll (HttpInstance->Tcp4);
}