MdeModulePkg/Network: Fix potential ASSERT if NetIp4IsUnicast is called
Cc: Hegde Nagaraj P <nagaraj-p.hegde@hpe.com> Cc: Subramanian Sriram <sriram-s@hpe.com> Cc: Zhang Lubo <lubo.zhang@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: Wu Jiaxin <jiaxin.wu@intel.com> Reviewed-by: Hegde Nagaraj P <nagaraj-p.hegde@hpe.com> Reviewed-by: Ye Ting <ting.ye@intel.com> Reviewed-by: Sriram Subramanian <sriram-s@hpe.com>
This commit is contained in:
@ -1,7 +1,7 @@
|
|||||||
/** @file
|
/** @file
|
||||||
Helper functions for configuring or getting the parameters relating to Ip4.
|
Helper functions for configuring or getting the parameters relating to Ip4.
|
||||||
|
|
||||||
Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
@ -615,13 +615,16 @@ Ip4Config2ConvertIfrNvDataToConfigNvData (
|
|||||||
}
|
}
|
||||||
|
|
||||||
Status = Ip4Config2StrToIp (IfrFormNvData->StationAddress, &StationAddress.v4);
|
Status = Ip4Config2StrToIp (IfrFormNvData->StationAddress, &StationAddress.v4);
|
||||||
if (EFI_ERROR (Status) || !NetIp4IsUnicast (NTOHL (StationAddress.Addr[0]), NTOHL (SubnetMask.Addr[0]))) {
|
if (EFI_ERROR (Status) ||
|
||||||
|
(SubnetMask.Addr[0] != 0 && !NetIp4IsUnicast (NTOHL (StationAddress.Addr[0]), NTOHL (SubnetMask.Addr[0]))) ||
|
||||||
|
!Ip4StationAddressValid (NTOHL (StationAddress.Addr[0]), NTOHL (SubnetMask.Addr[0]))) {
|
||||||
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid IP address!", NULL);
|
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid IP address!", NULL);
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = Ip4Config2StrToIp (IfrFormNvData->GatewayAddress, &Gateway.v4);
|
Status = Ip4Config2StrToIp (IfrFormNvData->GatewayAddress, &Gateway.v4);
|
||||||
if (EFI_ERROR (Status) || ((Gateway.Addr[0] != 0) && !NetIp4IsUnicast (NTOHL (Gateway.Addr[0]), NTOHL (SubnetMask.Addr[0])))) {
|
if (EFI_ERROR (Status) ||
|
||||||
|
(Gateway.Addr[0] != 0 && SubnetMask.Addr[0] != 0 && !NetIp4IsUnicast (NTOHL (Gateway.Addr[0]), NTOHL (SubnetMask.Addr[0])))) {
|
||||||
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Gateway!", NULL);
|
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Gateway!", NULL);
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
@ -208,7 +208,7 @@ Mtftp4OverrideValid (
|
|||||||
Netmask = NTOHL (Netmask);
|
Netmask = NTOHL (Netmask);
|
||||||
Ip = NTOHL (Ip);
|
Ip = NTOHL (Ip);
|
||||||
|
|
||||||
if (!NetIp4IsUnicast (Gateway, Netmask) || !IP4_NET_EQUAL (Gateway, Ip, Netmask)) {
|
if ((Netmask != 0 && !NetIp4IsUnicast (Gateway, Netmask)) || !IP4_NET_EQUAL (Gateway, Ip, Netmask)) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -668,13 +668,13 @@ EfiMtftp4Configure (
|
|||||||
ServerIp = NTOHL (ServerIp);
|
ServerIp = NTOHL (ServerIp);
|
||||||
|
|
||||||
if (!ConfigData->UseDefaultSetting &&
|
if (!ConfigData->UseDefaultSetting &&
|
||||||
((!IP4_IS_VALID_NETMASK (Netmask) || !NetIp4IsUnicast (Ip, Netmask)))) {
|
((!IP4_IS_VALID_NETMASK (Netmask) || (Netmask != 0 && !NetIp4IsUnicast (Ip, Netmask))))) {
|
||||||
|
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((Gateway != 0) &&
|
if ((Gateway != 0) &&
|
||||||
(!IP4_NET_EQUAL (Gateway, Ip, Netmask) || !NetIp4IsUnicast (Gateway, Netmask))) {
|
(!IP4_NET_EQUAL (Gateway, Ip, Netmask) || (Netmask != 0 && !NetIp4IsUnicast (Gateway, Netmask)))) {
|
||||||
|
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/** @file
|
/** @file
|
||||||
Implementation of TCP4 protocol services.
|
Implementation of TCP4 protocol services.
|
||||||
|
|
||||||
Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
@ -183,7 +183,8 @@ Tcp4Configure (
|
|||||||
|
|
||||||
CopyMem (&Ip, &TcpConfigData->AccessPoint.StationAddress, sizeof (IP4_ADDR));
|
CopyMem (&Ip, &TcpConfigData->AccessPoint.StationAddress, sizeof (IP4_ADDR));
|
||||||
CopyMem (&SubnetMask, &TcpConfigData->AccessPoint.SubnetMask, sizeof (IP4_ADDR));
|
CopyMem (&SubnetMask, &TcpConfigData->AccessPoint.SubnetMask, sizeof (IP4_ADDR));
|
||||||
if (!IP4_IS_VALID_NETMASK (NTOHL (SubnetMask)) || !NetIp4IsUnicast (NTOHL (Ip), NTOHL (SubnetMask))) {
|
if (!IP4_IS_VALID_NETMASK (NTOHL (SubnetMask)) ||
|
||||||
|
(SubnetMask != 0 && !NetIp4IsUnicast (NTOHL (Ip), NTOHL (SubnetMask)))) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/** @file
|
/** @file
|
||||||
|
|
||||||
(C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>
|
(C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>
|
||||||
Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
@ -172,7 +172,7 @@ Udp4Configure (
|
|||||||
|
|
||||||
if (!UdpConfigData->UseDefaultAddress &&
|
if (!UdpConfigData->UseDefaultAddress &&
|
||||||
(!IP4_IS_VALID_NETMASK (SubnetMask) ||
|
(!IP4_IS_VALID_NETMASK (SubnetMask) ||
|
||||||
!((StationAddress == 0) || NetIp4IsUnicast (StationAddress, SubnetMask)) ||
|
!((StationAddress == 0) || (SubnetMask != 0 && NetIp4IsUnicast (StationAddress, SubnetMask))) ||
|
||||||
IP4_IS_LOCAL_BROADCAST (RemoteAddress))) {
|
IP4_IS_LOCAL_BROADCAST (RemoteAddress))) {
|
||||||
//
|
//
|
||||||
// Don't use default address, and subnet mask is invalid or StationAddress is not
|
// Don't use default address, and subnet mask is invalid or StationAddress is not
|
||||||
|
@ -2321,7 +2321,7 @@ EfiPxeBcSetStationIP (
|
|||||||
if (NewStationIp != NULL) {
|
if (NewStationIp != NULL) {
|
||||||
if (IP4_IS_UNSPECIFIED(NTOHL (NewStationIp->Addr[0])) ||
|
if (IP4_IS_UNSPECIFIED(NTOHL (NewStationIp->Addr[0])) ||
|
||||||
IP4_IS_LOCAL_BROADCAST(NTOHL (NewStationIp->Addr[0])) ||
|
IP4_IS_LOCAL_BROADCAST(NTOHL (NewStationIp->Addr[0])) ||
|
||||||
(NewSubnetMask != NULL && !NetIp4IsUnicast (NTOHL (NewStationIp->Addr[0]), NTOHL (NewSubnetMask->Addr[0])))) {
|
(NewSubnetMask != NULL && NewSubnetMask->Addr[0] != 0 && !NetIp4IsUnicast (NTOHL (NewStationIp->Addr[0]), NTOHL (NewSubnetMask->Addr[0])))) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user