]> git.proxmox.com Git - mirror_edk2.git/commitdiff
This patch replaces StrCpy with StrnCpy or refactors out the usage of StrCpy through...
authorJaben Carsey <jaben.carsey@intel.com>
Fri, 29 Aug 2014 21:17:46 +0000 (21:17 +0000)
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 29 Aug 2014 21:17:46 +0000 (21:17 +0000)
This patch replaces StrCat with StrnCat or refactors out the usage of StrCat through some other means.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Erik Bjorge <erik.c.bjorge@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16003 6f19259b-4bc3-4df7-8a09-765794883524

ShellPkg/Library/UefiShellCommandLib/ConsistMapping.c
ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c

index 23ff12370e2d39eb31ce63fde1fd066d1724d442..a009609ffc27e08f727fce96f64ec2c5217bbed5 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Main file for support of shell consist mapping.\r
 \r
-  Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2005 - 2014, 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
@@ -98,7 +98,7 @@ CatPrint (
     ASSERT (Str->Str != NULL);\r
   }\r
 \r
-  StrCat (Str->Str, AppendStr);\r
+  StrnCat (Str->Str, AppendStr, StringSize/sizeof(CHAR16) - 1 - StrLen(Str->Str));\r
   Str->Len = StringSize;\r
 \r
   FreePool (AppendStr);\r
index b3939ea4d6fea2a6b6884d76fb6816bfdce22f1d..3829ba1f8c779f11407e7295c464a8a6fe070e79 100644 (file)
@@ -526,14 +526,9 @@ ShellCommandRegisterCommandName (
   //\r
   Node = AllocateZeroPool(sizeof(SHELL_COMMAND_INTERNAL_LIST_ENTRY));\r
   ASSERT(Node != NULL);\r
-  Node->CommandString = AllocateZeroPool(StrSize(CommandString));\r
+  Node->CommandString = AllocateCopyPool(StrSize(CommandString), CommandString);\r
   ASSERT(Node->CommandString != NULL);\r
 \r
-  //\r
-  // populate the new struct\r
-  //\r
-  StrCpy(Node->CommandString, CommandString);\r
-\r
   Node->GetManFileName  = GetManFileName;\r
   Node->CommandHandler  = CommandHandler;\r
   Node->LastError       = CanAffectLE;\r
@@ -792,17 +787,11 @@ ShellCommandRegisterAlias (
   //\r
   Node = AllocateZeroPool(sizeof(ALIAS_LIST));\r
   ASSERT(Node != NULL);\r
-  Node->CommandString = AllocateZeroPool(StrSize(Command));\r
-  Node->Alias = AllocateZeroPool(StrSize(Alias));\r
+  Node->CommandString = AllocateCopyPool(StrSize(Command), Command);\r
+  Node->Alias = AllocateCopyPool(StrSize(Alias), Alias);\r
   ASSERT(Node->CommandString != NULL);\r
   ASSERT(Node->Alias != NULL);\r
 \r
-  //\r
-  // populate the new struct\r
-  //\r
-  StrCpy(Node->CommandString, Command);\r
-  StrCpy(Node->Alias        , Alias );\r
-\r
   InsertHeadList (&mAliasList.Link, &Node->Link);\r
 \r
   //\r
@@ -1176,12 +1165,11 @@ ShellCommandAddMapItemAndUpdatePath(
     Status = EFI_OUT_OF_RESOURCES;\r
   } else {\r
     MapListNode->Flags = Flags;\r
-    MapListNode->MapName = AllocateZeroPool(StrSize(Name));\r
+    MapListNode->MapName = AllocateZeroPool(StrSize(Name), Name);\r
     MapListNode->DevicePath = DuplicateDevicePath(DevicePath);\r
     if ((MapListNode->MapName == NULL) || (MapListNode->DevicePath == NULL)){\r
       Status = EFI_OUT_OF_RESOURCES;\r
     } else {\r
-      StrCpy(MapListNode->MapName, Name);\r
       InsertTailList(&gShellMapList.Link, &MapListNode->Link);\r
     }\r
   }\r