]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
This patch replaces StrCpy with StrnCpy or refactors out the usage of StrCpy through...
[mirror_edk2.git] / ShellPkg / Library / UefiShellNetwork1CommandsLib / Ifconfig.c
index 32a4f7fb43ff61666893bf079f2669a71b17b013..9a85f917bb8d7e2db134cef6c450f0dd59c12458 100644 (file)
@@ -1,6 +1,7 @@
 /** @file\r
   The implementation for ifcommand shell command.\r
 \r
+  Copyright (c) 2013 Hewlett-Packard Development Company, L.P.\r
   Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
 \r
   This program and the accompanying materials\r
@@ -270,16 +271,16 @@ AppendOffsetWidthValue (
 \r
   OriString = String;\r
 \r
-  StrCpy (String, L"&OFFSET=");\r
+  StrnCpy (String, L"&OFFSET=", 9);\r
   String += StrLen (L"&OFFSET=");\r
   String += UnicodeSPrint (String, 20, L"%x", Offset);\r
 \r
-  StrCpy (String,L"&WIDTH=");\r
+  StrnCpy (String,L"&WIDTH=", 8);\r
   String += StrLen (L"&WIDTH=");\r
   String += UnicodeSPrint (String, 20, L"%x", Width);\r
 \r
   if (Block != NULL) {\r
-    StrCpy (String,L"&VALUE=");\r
+    StrnCpy (String,L"&VALUE=", 8);\r
     String += StrLen (L"&VALUE=");\r
     while ((Width--) != 0) {\r
       String += UnicodeSPrint (String, 20, L"%x", Block[Width]);\r
@@ -368,7 +369,7 @@ ConstructConfigHdr (
   } \r
 \r
   String = ConfigHdr;\r
-  StrCpy (String, L"GUID=");\r
+  StrnCpy (String, L"GUID=", 6);\r
   String += StrLen (L"GUID=");\r
 \r
   //\r
@@ -381,7 +382,7 @@ ConstructConfigHdr (
   //\r
   // Append L"&NAME="\r
   //\r
-  StrCpy (String, L"&NAME=");\r
+  StrnCpy (String, L"&NAME=", 7);\r
   String += StrLen (L"&NAME=");\r
   for (Index = 0; Index < NameLength ; Index++) {\r
     String += UnicodeSPrint (String, 10, L"00%x", Name[Index]);\r
@@ -390,7 +391,7 @@ ConstructConfigHdr (
   //\r
   // Append L"&PATH="\r
   //\r
-  StrCpy (String, L"&PATH=");\r
+  StrnCpy (String, L"&PATH=", 7);\r
   String += StrLen (L"&PATH=");\r
   for (Index = 0, Buffer = (UINT8 *) DevicePath; Index < DevicePathLength; Index++) {\r
     String += UnicodeSPrint (String, 6, L"%02x", *Buffer++);\r
@@ -617,7 +618,7 @@ IfconfigGetAllNicInfoByHii (
       goto ON_ERROR;\r
     }\r
     if (ConfigHdr != NULL) {\r
-      StrCpy (ConfigResp, ConfigHdr);\r
+      StrnCpy (ConfigResp, ConfigHdr, Length + NIC_ITEM_CONFIG_SIZE * 2 + 100);\r
     }\r
  \r
     //\r
@@ -790,7 +791,7 @@ IfconfigSetNicAddrByHii (
     goto ON_EXIT;\r
   }\r
   if (ConfigHdr != NULL) {\r
-    StrCpy (ConfigResp, ConfigHdr);\r
+    StrnCpy (ConfigResp, ConfigHdr, Length + NIC_ITEM_CONFIG_SIZE * 2 + 100);\r
   }\r
 \r
   NicConfig = AllocateZeroPool (NIC_ITEM_CONFIG_SIZE);\r
@@ -1249,7 +1250,7 @@ IfconfigSetNicAddr (
   \r
   if (StringNoCaseCompare(&Temp, &DhcpTemp) == 0) {\r
     //\r
-    // Validate the parameter for DHCP, two valid forms: eth0 DHCP and eth0 DHCP perment\r
+    // Validate the parameter for DHCP, two valid forms: eth0 DHCP and eth0 DHCP permanent\r
     //\r
     if ((Argc != 2) && (Argc!= 3)) {\r
       ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellNetwork1HiiHandle, Temp);\r
@@ -1274,7 +1275,7 @@ IfconfigSetNicAddr (
     }\r
 \r
     if ((OldConfig != NULL) && (OldConfig->Source == IP4_CONFIG_SOURCE_DHCP) &&\r
-        (OldConfig->Perment == Permanent)) {\r
+        (OldConfig->Permanent == Permanent)) {\r
 \r
       ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_IFCONFIG_INTERFACE_CONFIGURED), gShellNetwork1HiiHandle, Info->Name);\r
       ShellStatus = SHELL_ALREADY_STARTED;\r
@@ -1285,7 +1286,7 @@ IfconfigSetNicAddr (
   } else if (StringNoCaseCompare(&Temp, &StaticTemp) == 0) {\r
     //\r
     // validate the parameter, two forms: eth0 static IP NETMASK GATEWAY and\r
-    // eth0 static IP NETMASK GATEWAY perment\r
+    // eth0 static IP NETMASK GATEWAY permanent \r
     //\r
     if ((Argc != 5) && (Argc != 6)) {\r
       ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellNetwork1HiiHandle, Temp);\r
@@ -1388,7 +1389,7 @@ IfconfigSetNicAddr (
   }\r
 \r
   CopyMem (&Config->NicAddr, &Info->NicAddress, sizeof (NIC_ADDR));\r
-  Config->Perment = Permanent;\r
+  Config->Permanent = Permanent;\r
 \r
   //\r
   // Use HII service to set NIC address\r
@@ -1474,9 +1475,9 @@ IfconfigShowNicInfo (
     }\r
 \r
     ShellPrintHiiEx(-1, -1, NULL,\r
-      STRING_TOKEN (STR_IFCONFIG_PERMENT_STATUS),\r
+      STRING_TOKEN (STR_IFCONFIG_PERMANENT_STATUS),\r
       gShellNetwork1HiiHandle,\r
-      (NicInfo->ConfigInfo->Perment? L"TRUE":L"FALSE")\r
+      (NicInfo->ConfigInfo->Permanent? L"TRUE":L"FALSE")\r
       );\r
 \r
     Ip4Config = &NicInfo->ConfigInfo->Ip4Info;\r
@@ -1716,8 +1717,8 @@ ShellCommandRunIfconfig (
 \r
     //\r
     // The correct command line arguments for setting address are:\r
-    // IfConfig -s eth0 DHCP [perment]\r
-    // IfConfig -s eth0 static ip netmask gateway [perment]\r
+    // IfConfig -s eth0 DHCP [permanent]\r
+    // IfConfig -s eth0 static ip netmask gateway [permanent]\r
     //\r
     if (Item == NULL || (CountSubItems(Item) < 2) || (CountSubItems(Item) > 6) || (CountSubItems(Item) == 4)) {\r
       ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellNetwork1HiiHandle, L"-s");\r