diff options
author | jcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524> | 2013-02-22 18:20:55 +0000 |
---|---|---|
committer | jcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524> | 2013-02-22 18:20:55 +0000 |
commit | 7dd0562309ac668b7025023f05e79687fdf7a13a (patch) | |
tree | 48f313d94b23a015528994fa08fc965653066cc0 /ShellPkg | |
parent | 9bdcf582d178629e81cc109e274a63c8c668d6df (diff) | |
download | edk2-7dd0562309ac668b7025023f05e79687fdf7a13a.zip edk2-7dd0562309ac668b7025023f05e79687fdf7a13a.tar.gz edk2-7dd0562309ac668b7025023f05e79687fdf7a13a.tar.bz2 |
ShellPkg : Check pointer before dereferencing
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://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14144 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg')
-rw-r--r-- | ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c index 5dcb294..86ac960 100644 --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c @@ -146,14 +146,16 @@ CopySingleFile( Size = 0;
StrnCatGrow(&TempName, &Size, Source, 0);
StrnCatGrow(&TempName, &Size, L"\\*", 0);
- ShellOpenFileMetaArg((CHAR16*)TempName, EFI_FILE_MODE_READ, &List);
- *TempName = CHAR_NULL;
- StrnCatGrow(&TempName, &Size, Dest, 0);
- StrnCatGrow(&TempName, &Size, L"\\", 0);
- ShellStatus = ValidateAndCopyFiles(List, TempName, SilentMode, TRUE, Resp);
- ShellCloseFileMetaArg(&List);
- FreePool(TempName);
- Size = 0;
+ if (TempName != NULL) {
+ ShellOpenFileMetaArg((CHAR16*)TempName, EFI_FILE_MODE_READ, &List);
+ *TempName = CHAR_NULL;
+ StrnCatGrow(&TempName, &Size, Dest, 0);
+ StrnCatGrow(&TempName, &Size, L"\\", 0);
+ ShellStatus = ValidateAndCopyFiles(List, TempName, SilentMode, TRUE, Resp);
+ ShellCloseFileMetaArg(&List);
+ SHELL_FREE_NON_NULL(TempName);
+ Size = 0;
+ }
} else {
//
// open file with create enabled
|