summaryrefslogtreecommitdiff
path: root/MdeModulePkg
diff options
context:
space:
mode:
authorWang Fan <fan.wang@intel.com>2018-01-03 10:39:46 +0800
committerJiaxin Wu <jiaxin.wu@intel.com>2018-01-03 13:53:13 +0800
commit0ba795d21ad0df72ee3a12667d30ed7c64125b9c (patch)
tree9e6ac427d71c7f98039bd440fc11fad4553d77dc /MdeModulePkg
parentff260aa7abbeefdea591bb0b15e7d89e73d6c334 (diff)
downloadedk2-0ba795d21ad0df72ee3a12667d30ed7c64125b9c.zip
edk2-0ba795d21ad0df72ee3a12667d30ed7c64125b9c.tar.gz
edk2-0ba795d21ad0df72ee3a12667d30ed7c64125b9c.tar.bz2
MdeModulePkg: Add error handling when IP address is Class E
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>
Diffstat (limited to 'MdeModulePkg')
-rw-r--r--MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c
index aad6674..9e496ef 100644
--- a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c
+++ b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c
@@ -1,7 +1,7 @@
/** @file
This file implement the EFI_DHCP4_PROTOCOL interface.
-Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 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
which accompanies this distribution. The full text of the license may be found at
@@ -1186,8 +1186,10 @@ EfiDhcp4Build (
@param[in] UdpIo The UdpIo being created.
@param[in] Context Dhcp4 instance.
- @retval EFI_SUCCESS UdpIo is configured successfully.
- @retval other Other error occurs.
+ @retval EFI_SUCCESS UdpIo is configured successfully.
+ @retval EFI_INVALID_PARAMETER Class E IP address is not supported or other parameters
+ are not valid.
+ @retval other Other error occurs.
**/
EFI_STATUS
EFIAPI
@@ -1229,7 +1231,14 @@ Dhcp4InstanceConfigUdpIo (
// compute it according to the classful addressing rule.
//
Class = NetGetIpClass (ClientAddr);
+ //
+ // Class E IP address is not supported here!
+ //
ASSERT (Class < IP4_ADDR_CLASSE);
+ if (Class >= IP4_ADDR_CLASSE) {
+ return EFI_INVALID_PARAMETER;
+ }
+
SubnetMask = gIp4AllMasks[Class << 3];
} else {
SubnetMask = DhcpSb->Netmask;