diff options
author | Jiaxin Wu <jiaxin.wu@intel.com> | 2016-11-11 12:47:01 +0800 |
---|---|---|
committer | Jiaxin Wu <jiaxin.wu@intel.com> | 2016-11-17 08:21:13 +0800 |
commit | 818ba0ef81516c0cc8de3ff9a97495fd02e4c8a7 (patch) | |
tree | e5c26a06fcd2ffe2ff6266453fc14e34977bf980 /MdeModulePkg | |
parent | ad13d7d2d4a1d329a60b414843a888c54bdbad73 (diff) | |
download | edk2-platforms-818ba0ef81516c0cc8de3ff9a97495fd02e4c8a7.tar.xz |
MdeModulePkg/Ip4Dxe: Add wrong/invalid subnet check
v2:
* Separate out the return status fix.
* Replace IP4_MASK_MAX with IP4_MASK_NUM.
* Remove the ON_EXIT label.
This patch is used to add the wrong/invalid subnet check.
Cc: Santhapur Naveen <naveens@amiindia.co.in>
Cc: Laszlo Ersek <lersek@redhat.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: Jiaxin Wu <jiaxin.wu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Diffstat (limited to 'MdeModulePkg')
-rw-r--r-- | MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c | 10 | ||||
-rw-r--r-- | MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c | 8 |
2 files changed, 12 insertions, 6 deletions
diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c index a931bb3e77..5b01b35b76 100644 --- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c +++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c @@ -1255,6 +1255,13 @@ Ip4Config2SetMaunualAddress ( NewAddress = *((EFI_IP4_CONFIG2_MANUAL_ADDRESS *) Data);
+ StationAddress = EFI_NTOHL (NewAddress.Address);
+ SubnetMask = EFI_NTOHL (NewAddress.SubnetMask);
+
+ if (NetGetMaskLength (SubnetMask) == IP4_MASK_NUM) {
+ return EFI_INVALID_PARAMETER;
+ }
+
//
// Store the new data, and init the DataItem status to EFI_NOT_READY because
// we may have an asynchronous configuration process.
@@ -1273,9 +1280,6 @@ Ip4Config2SetMaunualAddress ( DataItem->DataSize = DataSize;
DataItem->Status = EFI_NOT_READY;
- StationAddress = EFI_NTOHL (NewAddress.Address);
- SubnetMask = EFI_NTOHL (NewAddress.SubnetMask);
-
IpSb->Reconfig = TRUE;
Status = Ip4Config2SetDefaultAddr (IpSb, StationAddress, SubnetMask);
if (EFI_ERROR (Status)) {
diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c index 9cd5dd547a..b0cc6a3dc7 100644 --- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c +++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c @@ -564,6 +564,11 @@ Ip4SetAddress ( NET_CHECK_SIGNATURE (Interface, IP4_INTERFACE_SIGNATURE);
+ Len = NetGetMaskLength (SubnetMask);
+ if (Len == IP4_MASK_NUM) {
+ return EFI_INVALID_PARAMETER;
+ }
+
//
// Set the ip/netmask, then compute the subnet broadcast
// and network broadcast for easy access. When computing
@@ -575,9 +580,6 @@ Ip4SetAddress ( Interface->Ip = IpAddr;
Interface->SubnetMask = SubnetMask;
Interface->SubnetBrdcast = (IpAddr | ~SubnetMask);
-
- Len = NetGetMaskLength (SubnetMask);
- ASSERT (Len <= IP4_MASK_MAX);
Interface->NetBrdcast = (IpAddr | ~SubnetMask);
//
|