NetworkPkg: Check for NULL pointer before dereference it.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
This commit is contained in:
Fu Siyuan 2016-10-31 10:21:39 +08:00
parent e86f363564
commit b340056060
1 changed files with 7 additions and 3 deletions

View File

@ -2013,10 +2013,14 @@ EfiPxeBcSetStationIP (
return EFI_INVALID_PARAMETER;
}
if (!Mode->UsingIpv6 && NewStationIp != NULL && !NetIp4IsUnicast (NTOHL (NewStationIp->Addr[0]), NTOHL (NewSubnetMask->Addr[0]))) {
return EFI_INVALID_PARAMETER;
if (!Mode->UsingIpv6 && NewStationIp != NULL) {
if (IP4_IS_UNSPECIFIED(NTOHL (NewStationIp->Addr[0])) ||
IP4_IS_LOCAL_BROADCAST(NTOHL (NewStationIp->Addr[0])) ||
(NewSubnetMask != NULL && !NetIp4IsUnicast (NTOHL (NewStationIp->Addr[0]), NTOHL (NewSubnetMask->Addr[0])))) {
return EFI_INVALID_PARAMETER;
}
}
if (!Mode->Started) {
return EFI_NOT_STARTED;
}