summaryrefslogtreecommitdiff
path: root/ShellPkg/Application/Shell/FileHandleWrappers.c
diff options
context:
space:
mode:
authorJaben Carsey <jaben.carsey@intel.com>2014-09-02 20:17:38 +0000
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>2014-09-02 20:17:38 +0000
commit7f79b01e8ef43901785dbccc1f4676cdf9a53d31 (patch)
treee47e56d49cd81748b1e48598a6e9f5a6c357311a /ShellPkg/Application/Shell/FileHandleWrappers.c
parent8ac6e336ff573f6105d4f776bdf7db1d189c7093 (diff)
downloadedk2-platforms-7f79b01e8ef43901785dbccc1f4676cdf9a53d31.tar.xz
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@16038 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg/Application/Shell/FileHandleWrappers.c')
-rw-r--r--ShellPkg/Application/Shell/FileHandleWrappers.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/ShellPkg/Application/Shell/FileHandleWrappers.c b/ShellPkg/Application/Shell/FileHandleWrappers.c
index 59c1ee55ee..be786bb2b5 100644
--- a/ShellPkg/Application/Shell/FileHandleWrappers.c
+++ b/ShellPkg/Application/Shell/FileHandleWrappers.c
@@ -509,21 +509,20 @@ FileInterfaceStdInRead(
if (StrStr(CurrentString + TabPos, L":") == NULL) {
Cwd = ShellInfoObject.NewEfiShellProtocol->GetCurDir(NULL);
if (Cwd != NULL) {
- StrCpy(TabStr, Cwd);
+ StrnCpy(TabStr, Cwd, (*BufferSize)/sizeof(CHAR16) - 1);
if (TabStr[StrLen(TabStr)-1] == L'\\' && *(CurrentString + TabPos) == L'\\' ) {
TabStr[StrLen(TabStr)-1] = CHAR_NULL;
}
StrnCat(TabStr, CurrentString + TabPos, (StringLen - TabPos) * sizeof (CHAR16));
} else {
- StrCpy(TabStr, L"");
+ *TabStr = CHAR_NULL;
StrnCat(TabStr, CurrentString + TabPos, (StringLen - TabPos) * sizeof (CHAR16));
}
} else {
- StrCpy(TabStr, CurrentString + TabPos);
+ StrnCpy(TabStr, CurrentString + TabPos, (*BufferSize)/sizeof(CHAR16) - 1);
}
- StrCat(TabStr, L"*");
+ StrnCat(TabStr, L"*", (*BufferSize)/sizeof(CHAR16) - 1 - StrLen(TabStr));
FoundFileList = NULL;
-// TabStr = PathCleanUpDirectories(TabStr);
Status = ShellInfoObject.NewEfiShellProtocol->FindFiles(TabStr, &FoundFileList);
for ( TempStr = CurrentString
; *TempStr == L' '
@@ -1168,7 +1167,7 @@ CreateFileInterfaceEnv(
EnvFileInterface->Delete = FileInterfaceEnvDelete;
EnvFileInterface->Read = FileInterfaceEnvRead;
- StrCpy(EnvFileInterface->Name, EnvName);
+ StrnCpy(EnvFileInterface->Name, EnvName, StrLen(EnvName));
//
// Assign the different members for Volatile and Non-Volatile variables