diff options
author | Qiu Shumin <shumin.qiu@intel.com> | 2014-09-10 01:03:43 +0000 |
---|---|---|
committer | shenshushi <shenshushi@6f19259b-4bc3-4df7-8a09-765794883524> | 2014-09-10 01:03:43 +0000 |
commit | 323d3d111843cb4fbdf4f9918f72d305e63bc091 (patch) | |
tree | 65fe284561ab6373083ab107196ccf14748de399 | |
parent | c9f4d4838ce92a6c2fb4faf5f46faa3b057b4dee (diff) | |
download | edk2-323d3d111843cb4fbdf4f9918f72d305e63bc091.zip edk2-323d3d111843cb4fbdf4f9918f72d305e63bc091.tar.gz edk2-323d3d111843cb4fbdf4f9918f72d305e63bc091.tar.bz2 |
ShellPkg: Replace the usage of StrnCpy with CopyMem to avoid potential buffer overflow and refine the code style.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <shumin.qiu@intel.com>
Signed-off-by: Yao Jiewen <jiewen.yao@intel.com>
Reviewed-by: Jaben Carsey <Jaben.carsey@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16083 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r-- | ShellPkg/Application/Shell/FileHandleWrappers.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/ShellPkg/Application/Shell/FileHandleWrappers.c b/ShellPkg/Application/Shell/FileHandleWrappers.c index be786bb..d3fc5dc 100644 --- a/ShellPkg/Application/Shell/FileHandleWrappers.c +++ b/ShellPkg/Application/Shell/FileHandleWrappers.c @@ -1140,6 +1140,7 @@ CreateFileInterfaceEnv( )
{
EFI_FILE_PROTOCOL_ENVIRONMENT *EnvFileInterface;
+ UINTN EnvNameSize;
if (EnvName == NULL) {
return (NULL);
@@ -1148,7 +1149,8 @@ CreateFileInterfaceEnv( //
// Get some memory
//
- EnvFileInterface = AllocateZeroPool(sizeof(EFI_FILE_PROTOCOL_ENVIRONMENT)+StrSize(EnvName));
+ EnvNameSize = StrSize(EnvName);
+ EnvFileInterface = AllocateZeroPool(sizeof(EFI_FILE_PROTOCOL_ENVIRONMENT)+EnvNameSize);
if (EnvFileInterface == NULL){
return (NULL);
}
@@ -1166,8 +1168,8 @@ CreateFileInterfaceEnv( EnvFileInterface->Flush = FileInterfaceNopGeneric;
EnvFileInterface->Delete = FileInterfaceEnvDelete;
EnvFileInterface->Read = FileInterfaceEnvRead;
-
- StrnCpy(EnvFileInterface->Name, EnvName, StrLen(EnvName));
+
+ CopyMem(EnvFileInterface->Name, EnvName, EnvNameSize);
//
// Assign the different members for Volatile and Non-Volatile variables
|