From 7f79b01e8ef43901785dbccc1f4676cdf9a53d31 Mon Sep 17 00:00:00 2001 From: Jaben Carsey Date: Tue, 2 Sep 2014 20:17:38 +0000 Subject: 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 Reviewed-by: Erik Bjorge git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16038 6f19259b-4bc3-4df7-8a09-765794883524 --- ShellPkg/Application/Shell/FileHandleWrappers.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'ShellPkg/Application/Shell/FileHandleWrappers.c') 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 -- cgit v1.2.3