From d0e76ac5ce07eb116f8cbea90b7f373d0c127a78 Mon Sep 17 00:00:00 2001 From: Jiaxin Wu Date: Tue, 21 Mar 2017 11:36:04 +0800 Subject: MdeModulePkg/Network: Fix potential ASSERT if NetIp4IsUnicast is called Cc: Hegde Nagaraj P Cc: Subramanian Sriram Cc: Zhang Lubo Cc: Ye Ting Cc: Fu Siyuan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wu Jiaxin Reviewed-by: Hegde Nagaraj P Reviewed-by: Ye Ting Reviewed-by: Sriram Subramanian --- MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c') diff --git a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c index a2583a490c..5494231166 100644 --- a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c +++ b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c @@ -208,7 +208,7 @@ Mtftp4OverrideValid ( Netmask = NTOHL (Netmask); 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; } } @@ -668,13 +668,13 @@ EfiMtftp4Configure ( ServerIp = NTOHL (ServerIp); 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; } - if ((Gateway != 0) && - (!IP4_NET_EQUAL (Gateway, Ip, Netmask) || !NetIp4IsUnicast (Gateway, Netmask))) { + if ((Gateway != 0) && + (!IP4_NET_EQUAL (Gateway, Ip, Netmask) || (Netmask != 0 && !NetIp4IsUnicast (Gateway, Netmask)))) { return EFI_INVALID_PARAMETER; } -- cgit v1.2.3