]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.c
MdeModulePkg/UefiHiiLib: Add error handling codes when AllocatePool fail
[mirror_edk2.git] / MdeModulePkg / Library / DxeIpIoLib / DxeIpIoLib.c
index cc93c2b89c01aaade9d1ef822348231d710acb18..ab4df80768dc5ef6433da7bf8c35d3d849aca5ac 100644 (file)
@@ -2,7 +2,7 @@
   IpIo Library.\r
 \r
 (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>\r
-Copyright (c) 2005 - 2009, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -1029,42 +1029,56 @@ IpIoListenHandlerDpc (
 \r
   if (IpIo->IpVersion == IP_VERSION_4) {\r
     if ((EFI_IP4 (RxData->Ip4RxData.Header->SourceAddress) != 0) &&\r
-      !NetIp4IsUnicast (EFI_NTOHL (((EFI_IP4_RECEIVE_DATA *) RxData)->Header->SourceAddress), 0)) {\r
+        !NetIp4IsUnicast (EFI_NTOHL (((EFI_IP4_RECEIVE_DATA *) RxData)->Header->SourceAddress), 0)) {\r
+      //\r
+      // The source address is not zero and it's not a unicast IP address, discard it.\r
+      //\r
+      goto CleanUp;\r
+    }\r
+\r
+    if (RxData->Ip4RxData.DataLength == 0) {\r
+      //\r
+      // Discard zero length data payload packet.\r
+      //\r
+      goto CleanUp;\r
+    }\r
+\r
     //\r
-    // The source address is not zero and it's not a unicast IP address, discard it.\r
+    // Create a netbuffer representing IPv4 packet\r
     //\r
-    goto CleanUp;\r
-  }\r
-\r
-  //\r
-  // Create a netbuffer representing IPv4 packet\r
-  //\r
-  Pkt = NetbufFromExt (\r
-          (NET_FRAGMENT *) RxData->Ip4RxData.FragmentTable,\r
-          RxData->Ip4RxData.FragmentCount,\r
-          0,\r
-          0,\r
-          IpIoExtFree,\r
-          RxData->Ip4RxData.RecycleSignal\r
-          );\r
-  if (NULL == Pkt) {\r
-    goto CleanUp;\r
-  }\r
+    Pkt = NetbufFromExt (\r
+            (NET_FRAGMENT *) RxData->Ip4RxData.FragmentTable,\r
+            RxData->Ip4RxData.FragmentCount,\r
+            0,\r
+            0,\r
+            IpIoExtFree,\r
+            RxData->Ip4RxData.RecycleSignal\r
+            );\r
+    if (NULL == Pkt) {\r
+      goto CleanUp;\r
+    }\r
 \r
-  //\r
-  // Create a net session\r
-  //\r
-  Session.Source.Addr[0] = EFI_IP4 (RxData->Ip4RxData.Header->SourceAddress);\r
-  Session.Dest.Addr[0]   = EFI_IP4 (RxData->Ip4RxData.Header->DestinationAddress);\r
-  Session.IpHdr.Ip4Hdr   = RxData->Ip4RxData.Header;\r
-  Session.IpHdrLen       = RxData->Ip4RxData.HeaderLength;\r
-  Session.IpVersion      = IP_VERSION_4;\r
+    //\r
+    // Create a net session\r
+    //\r
+    Session.Source.Addr[0] = EFI_IP4 (RxData->Ip4RxData.Header->SourceAddress);\r
+    Session.Dest.Addr[0]   = EFI_IP4 (RxData->Ip4RxData.Header->DestinationAddress);\r
+    Session.IpHdr.Ip4Hdr   = RxData->Ip4RxData.Header;\r
+    Session.IpHdrLen       = RxData->Ip4RxData.HeaderLength;\r
+    Session.IpVersion      = IP_VERSION_4;\r
   } else {\r
 \r
     if (!NetIp6IsValidUnicast(&RxData->Ip6RxData.Header->SourceAddress)) {\r
       goto CleanUp;\r
     }\r
     \r
+    if (RxData->Ip6RxData.DataLength == 0) {\r
+      //\r
+      // Discard zero length data payload packet.\r
+      //\r
+      goto CleanUp;\r
+    }\r
+    \r
     //\r
     // Create a netbuffer representing IPv6 packet\r
     //\r
@@ -1279,6 +1293,14 @@ IpIoOpen (
   // configure ip\r
   //\r
   if (IpVersion == IP_VERSION_4){\r
+    //\r
+    // RawData mode is no supported.\r
+    //\r
+    ASSERT (!OpenData->IpConfigData.Ip4CfgData.RawData);\r
+    if (OpenData->IpConfigData.Ip4CfgData.RawData) {\r
+      return EFI_UNSUPPORTED;\r
+    }\r
+    \r
     Status = IpIo->Ip.Ip4->Configure (\r
                              IpIo->Ip.Ip4,\r
                              &OpenData->IpConfigData.Ip4CfgData\r