summaryrefslogtreecommitdiff
path: root/NetworkPkg
diff options
context:
space:
mode:
authorZhang Lubo <lubo.zhang@intel.com>2015-11-26 08:17:46 +0000
committerluobozhang <luobozhang@Edk2>2015-11-26 08:17:46 +0000
commit1b96428d92c01383dc437717db679f57cf70d980 (patch)
tree02658004453856365213069ff9c0b6e3c9dc2995 /NetworkPkg
parent8e496a7abcb78c36b0af47ed473096ef7f171606 (diff)
downloadedk2-platforms-1b96428d92c01383dc437717db679f57cf70d980.tar.xz
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
Diffstat (limited to 'NetworkPkg')
-rw-r--r--NetworkPkg/HttpDxe/HttpImpl.c18
-rw-r--r--NetworkPkg/HttpDxe/HttpImpl.h1
-rw-r--r--NetworkPkg/HttpDxe/HttpProto.c52
3 files changed, 40 insertions, 31 deletions
diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c
index 4ad07d4f23..0fa437dc32 100644
--- a/NetworkPkg/HttpDxe/HttpImpl.c
+++ b/NetworkPkg/HttpDxe/HttpImpl.c
@@ -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);
}
diff --git a/NetworkPkg/HttpDxe/HttpImpl.h b/NetworkPkg/HttpDxe/HttpImpl.h
index 49c8af1b21..afbe982283 100644
--- a/NetworkPkg/HttpDxe/HttpImpl.h
+++ b/NetworkPkg/HttpDxe/HttpImpl.h
@@ -44,6 +44,7 @@
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.
**/
diff --git a/NetworkPkg/HttpDxe/HttpProto.c b/NetworkPkg/HttpDxe/HttpProto.c
index 999695125e..85f8401540 100644
--- a/NetworkPkg/HttpDxe/HttpProto.c
+++ b/NetworkPkg/HttpDxe/HttpProto.c
@@ -565,15 +565,14 @@ HttpCloseTcpRxEvent (
EFI_TCP4_IO_TOKEN *Rx4Token;
EFI_TCP6_IO_TOKEN *Rx6Token;
+ ASSERT (Wrap != NULL);
HttpInstance = Wrap->HttpInstance;
Rx4Token = NULL;
Rx6Token = NULL;
if (HttpInstance->LocalAddressIsIPv6) {
- if (Wrap != NULL) {
- if (Wrap->TcpWrap.Rx6Token.CompletionToken.Event != NULL) {
- gBS->CloseEvent (Wrap->TcpWrap.Rx6Token.CompletionToken.Event);
- }
+ if (Wrap->TcpWrap.Rx6Token.CompletionToken.Event != NULL) {
+ gBS->CloseEvent (Wrap->TcpWrap.Rx6Token.CompletionToken.Event);
}
if (HttpInstance->Rx6Token.CompletionToken.Event != NULL) {
@@ -581,10 +580,8 @@ HttpCloseTcpRxEvent (
HttpInstance->Rx6Token.CompletionToken.Event = NULL;
}
} else {
- if (Wrap != NULL) {
- if (Wrap->TcpWrap.Rx4Token.CompletionToken.Event != NULL) {
- gBS->CloseEvent (Wrap->TcpWrap.Rx4Token.CompletionToken.Event);
- }
+ if (Wrap->TcpWrap.Rx4Token.CompletionToken.Event != NULL) {
+ gBS->CloseEvent (Wrap->TcpWrap.Rx4Token.CompletionToken.Event);
}
if (HttpInstance->Rx4Token.CompletionToken.Event != NULL) {
@@ -1891,23 +1888,22 @@ HttpTcpTokenCleanup (
EFI_TCP4_IO_TOKEN *Rx4Token;
EFI_TCP6_IO_TOKEN *Rx6Token;
+ ASSERT (Wrap != NULL);
HttpInstance = Wrap->HttpInstance;
Rx4Token = NULL;
Rx6Token = NULL;
if (HttpInstance->LocalAddressIsIPv6) {
- if (Wrap != NULL) {
- if (Wrap->TcpWrap.Rx6Token.CompletionToken.Event != NULL) {
- gBS->CloseEvent (Wrap->TcpWrap.Rx6Token.CompletionToken.Event);
- }
+ if (Wrap->TcpWrap.Rx6Token.CompletionToken.Event != NULL) {
+ gBS->CloseEvent (Wrap->TcpWrap.Rx6Token.CompletionToken.Event);
+ }
- Rx6Token = &Wrap->TcpWrap.Rx6Token;
- if (Rx6Token->Packet.RxData->FragmentTable[0].FragmentBuffer != NULL) {
- FreePool (Rx6Token->Packet.RxData->FragmentTable[0].FragmentBuffer);
- Rx6Token->Packet.RxData->FragmentTable[0].FragmentBuffer = NULL;
- }
- FreePool (Wrap);
+ Rx6Token = &Wrap->TcpWrap.Rx6Token;
+ if (Rx6Token->Packet.RxData->FragmentTable[0].FragmentBuffer != NULL) {
+ FreePool (Rx6Token->Packet.RxData->FragmentTable[0].FragmentBuffer);
+ Rx6Token->Packet.RxData->FragmentTable[0].FragmentBuffer = NULL;
}
+ FreePool (Wrap);
if (HttpInstance->Rx6Token.CompletionToken.Event != NULL) {
gBS->CloseEvent (HttpInstance->Rx6Token.CompletionToken.Event);
@@ -1921,18 +1917,16 @@ HttpTcpTokenCleanup (
}
} else {
- if (Wrap != NULL) {
- if (Wrap->TcpWrap.Rx4Token.CompletionToken.Event != NULL) {
- gBS->CloseEvent (Wrap->TcpWrap.Rx4Token.CompletionToken.Event);
- }
- Rx4Token = &Wrap->TcpWrap.Rx4Token;
- if (Rx4Token->Packet.RxData->FragmentTable[0].FragmentBuffer != NULL) {
- FreePool (Rx4Token->Packet.RxData->FragmentTable[0].FragmentBuffer);
- Rx4Token->Packet.RxData->FragmentTable[0].FragmentBuffer = NULL;
- }
- FreePool (Wrap);
+ if (Wrap->TcpWrap.Rx4Token.CompletionToken.Event != NULL) {
+ gBS->CloseEvent (Wrap->TcpWrap.Rx4Token.CompletionToken.Event);
}
-
+ Rx4Token = &Wrap->TcpWrap.Rx4Token;
+ if (Rx4Token->Packet.RxData->FragmentTable[0].FragmentBuffer != NULL) {
+ FreePool (Rx4Token->Packet.RxData->FragmentTable[0].FragmentBuffer);
+ Rx4Token->Packet.RxData->FragmentTable[0].FragmentBuffer = NULL;
+ }
+ FreePool (Wrap);
+
if (HttpInstance->Rx4Token.CompletionToken.Event != NULL) {
gBS->CloseEvent (HttpInstance->Rx4Token.CompletionToken.Event);
HttpInstance->Rx4Token.CompletionToken.Event = NULL;