]> git.proxmox.com Git - mirror_edk2.git/commitdiff
NetworkPkg: Add ASSERT error handling for UDP6 driver
authorWang Fan <fan.wang@intel.com>
Wed, 3 Jan 2018 09:30:54 +0000 (17:30 +0800)
committerFu Siyuan <siyuan.fu@intel.com>
Thu, 11 Jan 2018 09:08:30 +0000 (17:08 +0800)
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>
NetworkPkg/Udp6Dxe/Udp6Impl.c
NetworkPkg/Udp6Dxe/Udp6Main.c

index edf2c23976d5a7625bb9e79f29c1e3afc6a2ba5d..25d4e6a80f4ed14c42bc4f45fa7e3d7c925ba96d 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Udp6 driver's whole implementation.\r
 \r
-  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -1608,6 +1608,10 @@ Udp6Demultiplex (
   //\r
   Udp6Header = (EFI_UDP_HEADER *) NetbufGetByte (Packet, 0, NULL);\r
   ASSERT (Udp6Header != NULL);\r
+  if (Udp6Header == NULL) {\r
+    NetbufFree (Packet);\r
+    return;\r
+  }\r
 \r
   if (Udp6Header->Checksum != 0) {\r
     //\r
@@ -1718,6 +1722,9 @@ Udp6SendPortUnreach (
   //\r
   Ip6ModeData = AllocateZeroPool (sizeof (EFI_IP6_MODE_DATA));\r
   ASSERT (Ip6ModeData != NULL);\r
+  if (Ip6ModeData == NULL) {\r
+    goto EXIT;\r
+  }\r
 \r
   //\r
   // If not finding the related IpSender use the default IpIo to send out\r
@@ -1766,6 +1773,9 @@ Udp6SendPortUnreach (
   //\r
   IcmpErrHdr = (IP6_ICMP_ERROR_HEAD *) NetbufAllocSpace (Packet, Len, FALSE);\r
   ASSERT (IcmpErrHdr != NULL);\r
+  if (IcmpErrHdr == NULL) {\r
+    goto EXIT;\r
+  }\r
 \r
   //\r
   // Set the required fields for the icmp port unreachable message.\r
@@ -1847,6 +1857,10 @@ Udp6IcmpHandler (
   \r
   Udp6Header = (EFI_UDP_HEADER *) NetbufGetByte (Packet, 0, NULL);\r
   ASSERT (Udp6Header != NULL);\r
+  if (Udp6Header == NULL) {\r
+    NetbufFree (Packet);\r
+    return;\r
+  }\r
 \r
   IP6_COPY_ADDRESS (&Udp6Session.SourceAddress, &NetSession->Source);\r
   IP6_COPY_ADDRESS (&Udp6Session.DestinationAddress, &NetSession->Dest);\r
index f3e99255f953cd6aeee284ed6994739df529143d..9105ef453fead209ae584961c1e27cf6318f68cb 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Contains all EFI_UDP6_PROTOCOL interfaces.\r
 \r
-  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -525,6 +525,11 @@ Udp6Transmit (
 \r
   Udp6Header = (EFI_UDP_HEADER *) NetbufAllocSpace (Packet, UDP6_HEADER_SIZE, TRUE);\r
   ASSERT (Udp6Header != NULL);\r
+  if (Udp6Header == NULL) {\r
+    Status = EFI_OUT_OF_RESOURCES;\r
+    goto ON_EXIT;\r
+  }\r
+  \r
   ConfigData = &Instance->ConfigData;\r
 \r
   //\r