diff options
author | Jaben Carsey <jaben.carsey@intel.com> | 2014-08-29 21:17:27 +0000 |
---|---|---|
committer | jcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524> | 2014-08-29 21:17:27 +0000 |
commit | 81957f8dfccd493ed77b5240b1c0c06f22defd2b (patch) | |
tree | 9a01cc1e2e5c21459730fd511017604586b41711 | |
parent | e87b40b2c71bcc943a1f9a186dc725789eeaf733 (diff) | |
download | edk2-platforms-81957f8dfccd493ed77b5240b1c0c06f22defd2b.tar.xz |
This patch replaces StrCpy with StrnCpy or refactors out the usage of StrCpy through some other means.
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@16002 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r-- | ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c | 15 | ||||
-rw-r--r-- | ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c | 8 |
2 files changed, 11 insertions, 12 deletions
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c index 5329be4192..ec204c30bc 100644 --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c @@ -228,13 +228,12 @@ MappingListHasType( // specific has priority
//
if (Specific != NULL) {
- NewSpecific = AllocateZeroPool(StrSize(Specific) + sizeof(CHAR16));
+ NewSpecific = AllocateCopyPool(StrSize(Specific) + sizeof(CHAR16), Specific);
if (NewSpecific == NULL){
return FALSE;
}
- StrCpy(NewSpecific, Specific);
if (NewSpecific[StrLen(NewSpecific)-1] != L':') {
- StrCat(NewSpecific, L":");
+ StrnCat(NewSpecific, L":", 2);
}
if (SearchList(MapList, NewSpecific, NULL, TRUE, FALSE, L";")) {
@@ -877,13 +876,12 @@ AddMappingFromMapping( EFI_STATUS Status;
CHAR16 *NewSName;
- NewSName = AllocateZeroPool(StrSize(SName) + sizeof(CHAR16));
+ NewSName = AllocateCopyPool(StrSize(SName) + sizeof(CHAR16), SName);
if (NewSName == NULL) {
return (SHELL_OUT_OF_RESOURCES);
}
- StrCpy(NewSName, SName);
if (NewSName[StrLen(NewSName)-1] != L':') {
- StrCat(NewSName, L":");
+ StrnCat(NewSName, L":", 2);
}
if (!IsNumberLetterOnly(NewSName, StrLen(NewSName)-1)) {
@@ -930,13 +928,12 @@ AddMappingFromHandle( EFI_STATUS Status;
CHAR16 *NewSName;
- NewSName = AllocateZeroPool(StrSize(SName) + sizeof(CHAR16));
+ NewSName = AllocateCopyPool(StrSize(SName) + sizeof(CHAR16), SName);
if (NewSName == NULL) {
return (SHELL_OUT_OF_RESOURCES);
}
- StrCpy(NewSName, SName);
if (NewSName[StrLen(NewSName)-1] != L':') {
- StrCat(NewSName, L":");
+ StrnCat(NewSName, L":", 2);
}
if (!IsNumberLetterOnly(NewSName, StrLen(NewSName)-1)) {
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c index a661b450e9..6cc5dcf691 100644 --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c @@ -77,6 +77,7 @@ CascadeDelete( EFI_STATUS Status;
SHELL_PROMPT_RESPONSE *Resp;
CHAR16 *TempName;
+ UINTN NewSize;
Resp = NULL;
ShellStatus = SHELL_SUCCESS;
@@ -125,13 +126,14 @@ CascadeDelete( //
// Update the node filename to have full path with file system identifier
//
- TempName = AllocateZeroPool(StrSize(Node->FullName) + StrSize(Node2->FullName));
+ NewSize = StrSize(Node->FullName) + StrSize(Node2->FullName);
+ TempName = AllocateZeroPool(NewSize);
if (TempName == NULL) {
ShellStatus = SHELL_OUT_OF_RESOURCES;
} else {
- StrCpy(TempName, Node->FullName);
+ StrnCpy(TempName, Node->FullName, NewSize/sizeof(CHAR16) -1);
TempName[StrStr(TempName, L":")+1-TempName] = CHAR_NULL;
- StrCat(TempName, Node2->FullName);
+ StrnCat(TempName, Node2->FullName, NewSize/sizeof(CHAR16) -1 - StrLen(TempName));
FreePool((VOID*)Node2->FullName);
Node2->FullName = TempName;
|