]> git.proxmox.com Git - mirror_edk2.git/blobdiff - NetworkPkg/Application/IfConfig6/IfConfig6.c
NetworkPkg:Replace unsafe string functions.
[mirror_edk2.git] / NetworkPkg / Application / IfConfig6 / IfConfig6.c
index 9e228ca7bc76b50e5af6ecb204f86e07f746fce3..4cec44f8d5e91ecf6428d731e1a18db46d88daa8 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The implementation for Shell application IfConfig6.\r
 \r
-  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2015, 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
@@ -127,16 +127,15 @@ SplitStrToList (
   ARG_LIST    *ArgList;\r
   ARG_LIST    *ArgNode;\r
 \r
-  if (*String == L'\0') {\r
+  if (*String == L'\0' || *String == NULL) {\r
     return NULL;\r
   }\r
 \r
   //\r
   // Copy the CONST string to a local copy.\r
   //\r
-  Str     = (CHAR16 *) AllocateZeroPool (StrSize (String));\r
+  Str     = AllocateCopyPool (StrSize (String), String);\r
   ASSERT (Str != NULL);\r
-  Str     = StrnCpy (Str, String, StrLen (String));\r
   ArgStr  = Str;\r
 \r
   //\r
@@ -1717,10 +1716,8 @@ IfConfig6Initialize (
     Private->OpCode = IfConfig6OpList;\r
     ValueStr = ShellCommandLineGetValue (ParamPackage, L"-l");\r
     if (ValueStr != NULL) {\r
-      Str             = (CHAR16 *) AllocateZeroPool (StrSize (ValueStr));\r
+      Str             = AllocateCopyPool (StrSize (ValueStr), ValueStr);\r
       ASSERT (Str != NULL);\r
-\r
-      Str             = StrnCpy (Str, ValueStr, StrLen (ValueStr));\r
       Private->IfName = Str;\r
     }\r
   }\r
@@ -1731,10 +1728,8 @@ IfConfig6Initialize (
     Private->OpCode = IfConfig6OpClear;\r
     ValueStr = ShellCommandLineGetValue (ParamPackage, L"-r");\r
     if (ValueStr != NULL) {\r
-      Str             = (CHAR16 *) AllocateZeroPool (StrSize (ValueStr));\r
+      Str             = AllocateCopyPool (StrSize (ValueStr), ValueStr);\r
       ASSERT (Str != NULL);\r
-\r
-      Str             = StrnCpy (Str, ValueStr, StrLen (ValueStr));\r
       Private->IfName = Str;\r
     }\r
   }\r