MdeModulePkg: 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:24 +08:00
parent 92ec8772df
commit e86f363564
1 changed files with 8 additions and 4 deletions

View File

@ -2318,9 +2318,13 @@ EfiPxeBcSetStationIP (
return EFI_INVALID_PARAMETER;
}
if (NewStationIp != NULL && !NetIp4IsUnicast (NTOHL (NewStationIp->Addr[0]), NTOHL (NewSubnetMask->Addr[0]))) {
if (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;
}
}
Private = PXEBC_PRIVATE_DATA_FROM_PXEBC (This);
Mode = Private->PxeBc.Mode;