diff options
author | Wang Fan <fan.wang@intel.com> | 2018-01-03 17:30:54 +0800 |
---|---|---|
committer | Fu Siyuan <siyuan.fu@intel.com> | 2018-01-11 17:08:30 +0800 |
commit | 2c4a45b3619303112d46df0d5a606842ad32d011 (patch) | |
tree | c3bbb30beb2d020c30e654bc049e0446b4252138 /NetworkPkg | |
parent | 0e8a782922c028cd04454a99d631e082c2153695 (diff) | |
download | edk2-2c4a45b3619303112d46df0d5a606842ad32d011.tar.gz edk2-2c4a45b3619303112d46df0d5a606842ad32d011.tar.bz2 edk2-2c4a45b3619303112d46df0d5a606842ad32d011.zip |
NetworkPkg: Add ASSERT error handling for UDP6 driver
In Udp6Dxe, there are several places use ASSERT to check returned
value. But these errors should be handled if they occur, this patch
is to fix this issue.
Cc: Ye Ting <ting.ye@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
Diffstat (limited to 'NetworkPkg')
-rw-r--r-- | NetworkPkg/Udp6Dxe/Udp6Impl.c | 16 | ||||
-rw-r--r-- | NetworkPkg/Udp6Dxe/Udp6Main.c | 7 |
2 files changed, 21 insertions, 2 deletions
diff --git a/NetworkPkg/Udp6Dxe/Udp6Impl.c b/NetworkPkg/Udp6Dxe/Udp6Impl.c index edf2c23976..25d4e6a80f 100644 --- a/NetworkPkg/Udp6Dxe/Udp6Impl.c +++ b/NetworkPkg/Udp6Dxe/Udp6Impl.c @@ -1,7 +1,7 @@ /** @file
Udp6 driver's whole implementation.
- Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -1608,6 +1608,10 @@ Udp6Demultiplex ( //
Udp6Header = (EFI_UDP_HEADER *) NetbufGetByte (Packet, 0, NULL);
ASSERT (Udp6Header != NULL);
+ if (Udp6Header == NULL) {
+ NetbufFree (Packet);
+ return;
+ }
if (Udp6Header->Checksum != 0) {
//
@@ -1718,6 +1722,9 @@ Udp6SendPortUnreach ( //
Ip6ModeData = AllocateZeroPool (sizeof (EFI_IP6_MODE_DATA));
ASSERT (Ip6ModeData != NULL);
+ if (Ip6ModeData == NULL) {
+ goto EXIT;
+ }
//
// If not finding the related IpSender use the default IpIo to send out
@@ -1766,6 +1773,9 @@ Udp6SendPortUnreach ( //
IcmpErrHdr = (IP6_ICMP_ERROR_HEAD *) NetbufAllocSpace (Packet, Len, FALSE);
ASSERT (IcmpErrHdr != NULL);
+ if (IcmpErrHdr == NULL) {
+ goto EXIT;
+ }
//
// Set the required fields for the icmp port unreachable message.
@@ -1847,6 +1857,10 @@ Udp6IcmpHandler ( Udp6Header = (EFI_UDP_HEADER *) NetbufGetByte (Packet, 0, NULL);
ASSERT (Udp6Header != NULL);
+ if (Udp6Header == NULL) {
+ NetbufFree (Packet);
+ return;
+ }
IP6_COPY_ADDRESS (&Udp6Session.SourceAddress, &NetSession->Source);
IP6_COPY_ADDRESS (&Udp6Session.DestinationAddress, &NetSession->Dest);
diff --git a/NetworkPkg/Udp6Dxe/Udp6Main.c b/NetworkPkg/Udp6Dxe/Udp6Main.c index f3e99255f9..9105ef453f 100644 --- a/NetworkPkg/Udp6Dxe/Udp6Main.c +++ b/NetworkPkg/Udp6Dxe/Udp6Main.c @@ -1,7 +1,7 @@ /** @file
Contains all EFI_UDP6_PROTOCOL interfaces.
- Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -525,6 +525,11 @@ Udp6Transmit ( Udp6Header = (EFI_UDP_HEADER *) NetbufAllocSpace (Packet, UDP6_HEADER_SIZE, TRUE);
ASSERT (Udp6Header != NULL);
+ if (Udp6Header == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto ON_EXIT;
+ }
+
ConfigData = &Instance->ConfigData;
//
|