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>
This commit is contained in:
@@ -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);
|
||||
|
||||
//
|
||||
|
Reference in New Issue
Block a user