]> git.proxmox.com Git - mirror_edk2.git/blobdiff - NetworkPkg/Udp6Dxe/Udp6Impl.c
NetworkPkg: Add ASSERT error handling for UDP6 driver
[mirror_edk2.git] / NetworkPkg / Udp6Dxe / Udp6Impl.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