]> git.proxmox.com Git - mirror_edk2.git/commitdiff
NetworkPkg: Fix potential ASSERT if NetIp4IsUnicast is called
authorJiaxin Wu <jiaxin.wu@intel.com>
Tue, 21 Mar 2017 03:36:31 +0000 (11:36 +0800)
committerJiaxin Wu <jiaxin.wu@intel.com>
Thu, 23 Mar 2017 03:39:31 +0000 (11:39 +0800)
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>
NetworkPkg/DnsDxe/DnsProtocol.c
NetworkPkg/TcpDxe/TcpMain.c
NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c

index 6d117b2892d336346d4e633b406fc60936f7fbeb..0e7ed34b4e0c73e9d9691f90aa200b2053d36f33 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 Implementation of EFI_DNS4_PROTOCOL and EFI_DNS6_PROTOCOL interfaces.\r
 \r
-Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -246,7 +246,7 @@ Dns4Configure (
     Netmask  = NTOHL (Netmask);\r
 \r
     if (!DnsConfigData->UseDefaultSetting &&\r
-       ((!IP4_IS_VALID_NETMASK (Netmask) || !NetIp4IsUnicast (Ip, Netmask)))) {\r
+        ((!IP4_IS_VALID_NETMASK (Netmask) || (Netmask != 0 && !NetIp4IsUnicast (Ip, Netmask))))) {\r
       Status = EFI_INVALID_PARAMETER;\r
       goto ON_EXIT;\r
     }\r
index 03942ee32e440c67fe449426315829ed9609d1b2..fc3713e53322efafe0c827a93e4abc838c02e301 100644 (file)
@@ -2,7 +2,7 @@
   Implementation of EFI_TCP4_PROTOCOL and EFI_TCP6_PROTOCOL.\r
 \r
   (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>\r
-  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -159,7 +159,8 @@ Tcp4Configure (
 \r
       CopyMem (&Ip, &TcpConfigData->AccessPoint.StationAddress, sizeof (IP4_ADDR));\r
       CopyMem (&SubnetMask, &TcpConfigData->AccessPoint.SubnetMask, sizeof (IP4_ADDR));\r
-      if (!IP4_IS_VALID_NETMASK (NTOHL (SubnetMask)) || !NetIp4IsUnicast (NTOHL (Ip), NTOHL (SubnetMask))) {\r
+      if (!IP4_IS_VALID_NETMASK (NTOHL (SubnetMask)) || \r
+          (SubnetMask != 0 && !NetIp4IsUnicast (NTOHL (Ip), NTOHL (SubnetMask)))) {\r
         return EFI_INVALID_PARAMETER;\r
       }\r
     }\r
index 36477e9f80d9d12087460296984c96bc003851bf..ab9e494b56800a449c348978507b19514fb0b973 100644 (file)
@@ -1085,7 +1085,8 @@ EfiPxeBcUdpWrite (
     DoNotFragment = TRUE;\r
   }\r
 \r
-  if (!Mode->UsingIpv6 && GatewayIp != NULL && !NetIp4IsUnicast (NTOHL (GatewayIp->Addr[0]), EFI_NTOHL(Mode->SubnetMask))) {\r
+  if (!Mode->UsingIpv6 && GatewayIp != NULL && Mode->SubnetMask.Addr[0] != 0 && \r
+      !NetIp4IsUnicast (NTOHL (GatewayIp->Addr[0]), EFI_NTOHL(Mode->SubnetMask))) {\r
     //\r
     // Gateway is provided but it's not a unicast IPv4 address, while it will be ignored for IPv6.\r
     //\r
@@ -2016,7 +2017,7 @@ EfiPxeBcSetStationIP (
   if (!Mode->UsingIpv6 && NewStationIp != NULL) {\r
     if (IP4_IS_UNSPECIFIED(NTOHL (NewStationIp->Addr[0])) || \r
         IP4_IS_LOCAL_BROADCAST(NTOHL (NewStationIp->Addr[0])) ||\r
-        (NewSubnetMask != NULL && !NetIp4IsUnicast (NTOHL (NewStationIp->Addr[0]), NTOHL (NewSubnetMask->Addr[0])))) {\r
+        (NewSubnetMask != NULL && NewSubnetMask->Addr[0] != 0 && !NetIp4IsUnicast (NTOHL (NewStationIp->Addr[0]), NTOHL (NewSubnetMask->Addr[0])))) {\r
       return EFI_INVALID_PARAMETER;\r
     }\r
   }\r