diff options
author | jaben carsey <jaben.carsey@intel.com> | 2013-06-28 22:44:21 +0000 |
---|---|---|
committer | jcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524> | 2013-06-28 22:44:21 +0000 |
commit | 7461437cf15b9ff49b2c3cc722d05182dca9a46a (patch) | |
tree | c0a5c8bd1ce15e3a8620ab2e31c084cec77f6036 /ShellPkg | |
parent | a58266e5fde9ed7e0e88f0b039ae68e926745dc5 (diff) | |
download | edk2-7461437cf15b9ff49b2c3cc722d05182dca9a46a.tar.gz edk2-7461437cf15b9ff49b2c3cc722d05182dca9a46a.tar.bz2 edk2-7461437cf15b9ff49b2c3cc722d05182dca9a46a.zip |
ShellPkg: Verify memory and handle allocation failure.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: jaben carsey <jaben.carsey@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14448 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg')
-rw-r--r-- | ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c index e1473cf907..e4f4166b14 100644 --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c @@ -126,18 +126,26 @@ CascadeDelete( // Update the node filename to have full path with file system identifier
//
TempName = AllocateZeroPool(StrSize(Node->FullName) + StrSize(Node2->FullName));
- StrCpy(TempName, Node->FullName);
- TempName[StrStr(TempName, L":")+1-TempName] = CHAR_NULL;
- StrCat(TempName, Node2->FullName);
- FreePool((VOID*)Node2->FullName);
- Node2->FullName = TempName;
-
- //
- // Now try again to open the file
- //
- Node2->Status = gEfiShellProtocol->OpenFileByName (Node2->FullName, &Node2->Handle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE);
+ if (TempName == NULL) {
+ ShellStatus = EFI_OUT_OF_RESOURCES;
+ } else {
+ StrCpy(TempName, Node->FullName);
+ TempName[StrStr(TempName, L":")+1-TempName] = CHAR_NULL;
+ StrCat(TempName, Node2->FullName);
+ FreePool((VOID*)Node2->FullName);
+ Node2->FullName = TempName;
+
+ //
+ // Now try again to open the file
+ //
+ Node2->Status = gEfiShellProtocol->OpenFileByName (Node2->FullName, &Node2->Handle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE);
+ }
+ }
+ if (!EFI_ERROR(Node2->Status)) {
+ ShellStatus = CascadeDelete(Node2, Quiet);
+ } else if (ShellStatus == SHELL_SUCCESS) {
+ ShellStatus = Node2->Status;
}
- ShellStatus = CascadeDelete(Node2, Quiet);
if (ShellStatus != SHELL_SUCCESS) {
if (List!=NULL) {
gEfiShellProtocol->FreeFileList(&List);
|