]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
MdeModulePkg/Network: Fix potential ASSERT if NetIp4IsUnicast is called
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Ip4Dxe / Ip4Config2Impl.c
index a6a3da8fe8a0821e8f54ddae6a1593d037f3bd3b..f4dfbb6e31a730f0529eaaab6c4327aaf8a3a3c1 100644 (file)
@@ -609,6 +609,13 @@ Ip4Config2SetDefaultIf (
 \r
   IpSb = IP4_SERVICE_FROM_IP4_CONFIG2_INSTANCE (Instance);\r
 \r
+  //\r
+  // Check whether the StationAddress/SubnetMask pair is valid.\r
+  //\r
+  if (!Ip4StationAddressValid (StationAddress, SubnetMask)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
   Status = Ip4Config2SetDefaultAddr (IpSb, StationAddress, SubnetMask);\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
@@ -705,7 +712,6 @@ Ip4Config2SetDnsServerWorker (
 {\r
   UINTN                 OldIndex;\r
   UINTN                 NewIndex;\r
-  UINTN                 Index1;\r
   EFI_IPv4_ADDRESS      *OldDns;\r
   EFI_IPv4_ADDRESS      *NewDns;\r
   UINTN                 OldDnsCount;\r
@@ -747,15 +753,6 @@ Ip4Config2SetDnsServerWorker (
       return EFI_INVALID_PARAMETER;\r
     }\r
 \r
-    for (Index1 = NewIndex + 1; Index1 < NewDnsCount; Index1++) {\r
-      if (EFI_IP4_EQUAL (NewDns + NewIndex, NewDns + Index1)) {\r
-        if (Tmp != NULL) {\r
-          FreePool (Tmp);\r
-        }\r
-        return EFI_INVALID_PARAMETER;\r
-      }\r
-    }\r
-\r
     if (OneAdded) {\r
       //\r
       // If any address in the new setting is not in the old settings, skip the\r
@@ -1262,7 +1259,10 @@ Ip4Config2SetMaunualAddress (
   StationAddress = EFI_NTOHL (NewAddress.Address);\r
   SubnetMask = EFI_NTOHL (NewAddress.SubnetMask);\r
 \r
-  if (NetGetMaskLength (SubnetMask) == IP4_MASK_NUM) {\r
+  //\r
+  // Check whether the StationAddress/SubnetMask pair is valid.\r
+  //\r
+  if (!Ip4StationAddressValid (StationAddress, SubnetMask)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -1495,7 +1495,7 @@ Ip4Config2InitIfInfo (
   UnicodeSPrint (\r
     IfInfo->Name,\r
     EFI_IP4_CONFIG2_INTERFACE_INFO_NAME_SIZE,\r
-    L"eth%x",\r
+    L"eth%d",\r
     IpSb->Ip4Config2Instance.IfIndex\r
   );\r
 \r