]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg: Add error handling when IP address is Class E
authorWang Fan <fan.wang@intel.com>
Wed, 3 Jan 2018 02:39:46 +0000 (10:39 +0800)
committerJiaxin Wu <jiaxin.wu@intel.com>
Wed, 3 Jan 2018 05:53:13 +0000 (13:53 +0800)
The Dhcp4.TransmitReceive() API should be able to use at any time according
to UEFI spec. While in classless addressing network, the netmask must be
explicitly provided together with the station address.
But if the DHCP instance haven't be configured with a valid netmask, we need
compute it according to the classful addressing rule. In such case, if the
user configures with class E IP address, ASSERT will happen, we need to handle
this case and return error status code.

Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Ye Ting <ting.ye@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>
MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c

index aad667483a212d7b1056d39e47a4b7bf9e2daca9..9e496ef02711de18e2761ca80b36798d778b5513 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   This file implement the EFI_DHCP4_PROTOCOL interface.\r
 \r
-Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2018, 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
@@ -1186,8 +1186,10 @@ EfiDhcp4Build (
   @param[in] UdpIo      The UdpIo being created.\r
   @param[in] Context    Dhcp4 instance.\r
 \r
-  @retval EFI_SUCCESS   UdpIo is configured successfully.\r
-  @retval other         Other error occurs.\r
+  @retval EFI_SUCCESS              UdpIo is configured successfully.\r
+  @retval EFI_INVALID_PARAMETER    Class E IP address is not supported or other parameters\r
+                                   are not valid.\r
+  @retval other                    Other error occurs.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -1229,7 +1231,14 @@ Dhcp4InstanceConfigUdpIo (
     // compute it according to the classful addressing rule.\r
     //\r
     Class = NetGetIpClass (ClientAddr);\r
+    //\r
+    //  Class E IP address is not supported here!\r
+    //\r
     ASSERT (Class < IP4_ADDR_CLASSE);\r
+    if (Class >= IP4_ADDR_CLASSE) {\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+    \r
     SubnetMask = gIp4AllMasks[Class << 3];\r
   } else {\r
     SubnetMask = DhcpSb->Netmask;\r