diff options
author | Jaben Carsey <jaben.carsey@intel.com> | 2014-08-22 16:06:55 +0000 |
---|---|---|
committer | jcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524> | 2014-08-22 16:06:55 +0000 |
commit | cea5e3b9bfd55f32d7f8b0df5d613e38597d28a1 (patch) | |
tree | 1c2684e595722ff7f6b005684250bd6d62a99513 /ShellPkg | |
parent | cd92f93847f8d79e2e4e1e81dead208d0feec5f6 (diff) | |
download | edk2-cea5e3b9bfd55f32d7f8b0df5d613e38597d28a1.zip edk2-cea5e3b9bfd55f32d7f8b0df5d613e38597d28a1.tar.gz edk2-cea5e3b9bfd55f32d7f8b0df5d613e38597d28a1.tar.bz2 |
ShellPkg: Refactor string manipulation
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@15882 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg')
-rw-r--r-- | ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c | 5 | ||||
-rw-r--r-- | ShellPkg/Library/UefiShellLevel2CommandsLib/Vol.c | 6 |
2 files changed, 5 insertions, 6 deletions
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c index c0d3c92..aa5a208 100644 --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c @@ -1,7 +1,7 @@ /** @file
Main file for attrib shell level 2 function.
- Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -194,12 +194,11 @@ ShellCommandRunCd ( //
// change directory with a drive letter
//
- Drive = AllocateZeroPool(StrSize(Param1Copy));
+ Drive = AllocateCopyPool(StrSize(Param1Copy), Param1Copy);
if (Drive == NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_MEM), gShellLevel2HiiHandle);
ShellStatus = SHELL_OUT_OF_RESOURCES;
} else {
- Drive = StrCpy(Drive, Param1Copy);
Path = StrStr(Drive, L":");
ASSERT(Path != NULL);
if (EFI_ERROR(ShellIsDirectory(Param1Copy))) {
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Vol.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Vol.c index 9300d5e..4b6d2ea 100644 --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Vol.c +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Vol.c @@ -1,7 +1,7 @@ /** @file
Main file for vol shell level 2 function.
- Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -101,7 +101,7 @@ HandleVol( ASSERT(SysInfo != NULL);
if (Delete) {
- StrCpy ((CHAR16 *) SysInfo->VolumeLabel, L"");
+ *((CHAR16 *) SysInfo->VolumeLabel) = CHAR_NULL;
SysInfo->Size = SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize(SysInfo->VolumeLabel);
Status = EfiFpHandle->SetInfo(
EfiFpHandle,
@@ -119,7 +119,7 @@ HandleVol( }
}
if (SysInfo != NULL) {
- StrCpy ((CHAR16 *) SysInfo->VolumeLabel, Name);
+ StrnCpy ((CHAR16 *) SysInfo->VolumeLabel, Name, (Size1 > Size2?Size1/sizeof(CHAR16):Size2/sizeof(CHAR16))-1);
SysInfo->Size = SIZE_OF_EFI_FILE_SYSTEM_INFO + Size1;
Status = EfiFpHandle->SetInfo(
EfiFpHandle,
|