From 01b5ac880f00cf89833e6fc80666bccc9779dea7 Mon Sep 17 00:00:00 2001 From: Fu Siyuan Date: Thu, 27 Oct 2016 09:23:08 +0800 Subject: MdeModulePkg: Update IP4 stack drivers for classless address unicast check. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Fu Siyuan Reviewed-by: Ye Ting Reviewed-by: Wu Jiaxin --- .../Universal/Network/UefiPxeBcDxe/PxeBcImpl.c | 24 ++++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'MdeModulePkg/Universal/Network/UefiPxeBcDxe') diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c index cf7b7b566e..4746256fa0 100644 --- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c +++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c @@ -176,7 +176,9 @@ IcmpErrorListenHandlerDpc ( } if (EFI_IP4 (RxData->Header->SourceAddress) != 0 && - !NetIp4IsUnicast (EFI_NTOHL (RxData->Header->SourceAddress), 0)) { + (NTOHL (Mode->SubnetMask.Addr[0]) != 0) && + IP4_NET_EQUAL (NTOHL(Mode->StationIp.Addr[0]), EFI_NTOHL (RxData->Header->SourceAddress), NTOHL (Mode->SubnetMask.Addr[0])) && + !NetIp4IsUnicast (EFI_NTOHL (RxData->Header->SourceAddress), NTOHL (Mode->SubnetMask.Addr[0]))) { // // The source address is not zero and it's not a unicast IP address, discard it. // @@ -1163,7 +1165,9 @@ EfiPxeBcMtftp ( if ((This == NULL) || (Filename == NULL) || (BufferSize == NULL) || - ((ServerIp == NULL) || !NetIp4IsUnicast (NTOHL (ServerIp->Addr[0]), 0)) || + ((ServerIp == NULL) || + (IP4_IS_UNSPECIFIED (NTOHL (ServerIp->Addr[0])) || + IP4_IS_LOCAL_BROADCAST (NTOHL (ServerIp->Addr[0])))) || ((BufferPtr == NULL) && DontUseBuffer) || ((BlockSize != NULL) && (*BlockSize < 512))) { @@ -1378,7 +1382,7 @@ EfiPxeBcUdpWrite ( return EFI_INVALID_PARAMETER; } - if ((GatewayIp != NULL) && !NetIp4IsUnicast (NTOHL (GatewayIp->Addr[0]), 0)) { + if ((GatewayIp != NULL) && (IP4_IS_UNSPECIFIED (NTOHL (GatewayIp->Addr[0])) || IP4_IS_LOCAL_BROADCAST (NTOHL (GatewayIp->Addr[0])))) { // // Gateway is provided but it's not a unicast IP address. // @@ -1964,9 +1968,11 @@ EfiPxeBcSetIpFilter ( DEBUG ((EFI_D_ERROR, "There is broadcast address in NewFilter.\n")); return EFI_INVALID_PARAMETER; } - if (NetIp4IsUnicast (EFI_IP4 (NewFilter->IpList[Index].v4), 0) && - ((NewFilter->Filters & EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP) != 0) - ) { + if ((EFI_NTOHL(Mode->StationIp) != 0) && + (EFI_NTOHL(Mode->SubnetMask) != 0) && + IP4_NET_EQUAL(EFI_NTOHL(Mode->StationIp), EFI_NTOHL(NewFilter->IpList[Index].v4), EFI_NTOHL(Mode->SubnetMask)) && + NetIp4IsUnicast (EFI_IP4 (NewFilter->IpList[Index].v4), EFI_NTOHL(Mode->SubnetMask)) && + ((NewFilter->Filters & EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP) != 0)) { // // If EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP is set and IP4 address is in IpList, // promiscuous mode is needed. @@ -2308,11 +2314,11 @@ EfiPxeBcSetStationIP ( return EFI_INVALID_PARAMETER; } - if (NewStationIp != NULL && !NetIp4IsUnicast (NTOHL (NewStationIp->Addr[0]), 0)) { + if (NewSubnetMask != NULL && !IP4_IS_VALID_NETMASK (NTOHL (NewSubnetMask->Addr[0]))) { return EFI_INVALID_PARAMETER; } - - if (NewSubnetMask != NULL && !IP4_IS_VALID_NETMASK (NTOHL (NewSubnetMask->Addr[0]))) { + + if (NewStationIp != NULL && !NetIp4IsUnicast (NTOHL (NewStationIp->Addr[0]), NTOHL (NewSubnetMask->Addr[0]))) { return EFI_INVALID_PARAMETER; } -- cgit v1.2.3