MdeModulePkg/Ip4Dxe: Add Ip/Netmask pair check for Ip4Config2
v2: * Add the check in Ip4Config2SetDefaultIf to avoid the DHCP configuration case. Ip4config2 doesn't check the validity of Ip/Netmask pair, which leads to the invalid combination of Ip and Netmask setting. This patch is to resolve the issue. Cc: Hegde Nagaraj P <nagaraj-p.hegde@hpe.com> Cc: Subramanian Sriram <sriram-s@hpe.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: Wu Jiaxin <jiaxin.wu@intel.com> Reviewed-by: Sriram Subramanian <sriram-s@hpe.com> Reviewed-by: Hegde Nagaraj P <nagaraj-p.hegde@hpe.com>
This commit is contained in:
@@ -609,6 +609,13 @@ Ip4Config2SetDefaultIf (
|
||||
|
||||
IpSb = IP4_SERVICE_FROM_IP4_CONFIG2_INSTANCE (Instance);
|
||||
|
||||
//
|
||||
// Check whether the StationAddress/SubnetMask pair is valid.
|
||||
//
|
||||
if (!Ip4StationAddressValid (StationAddress, SubnetMask)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Status = Ip4Config2SetDefaultAddr (IpSb, StationAddress, SubnetMask);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
@@ -1252,7 +1259,10 @@ Ip4Config2SetMaunualAddress (
|
||||
StationAddress = EFI_NTOHL (NewAddress.Address);
|
||||
SubnetMask = EFI_NTOHL (NewAddress.SubnetMask);
|
||||
|
||||
if (NetGetMaskLength (SubnetMask) == IP4_MASK_NUM) {
|
||||
//
|
||||
// Check whether the StationAddress/SubnetMask pair is valid.
|
||||
//
|
||||
if (!Ip4StationAddressValid (StationAddress, SubnetMask)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user