diff options
author | Eric Dong <eric.dong@intel.com> | 2014-06-26 01:38:46 +0000 |
---|---|---|
committer | ydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524> | 2014-06-26 01:38:46 +0000 |
commit | 81cd2f536ef0097392b51f96405321ce7b01350c (patch) | |
tree | ce44817456c749b0663e8fb845c9d91b8aefbce3 /ShellPkg/Library/UefiShellDebug1CommandsLib/Bcfg.c | |
parent | 45295cf5a58578b84e5092c3a3dd145c069c1db5 (diff) | |
download | edk2-platforms-81cd2f536ef0097392b51f96405321ce7b01350c.tar.xz |
Refine code to make it more safely.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Jaben Carsey <Jaben.carsey@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15593 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg/Library/UefiShellDebug1CommandsLib/Bcfg.c')
-rw-r--r-- | ShellPkg/Library/UefiShellDebug1CommandsLib/Bcfg.c | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Bcfg.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Bcfg.c index b19d8d9fb8..483aa5855e 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Bcfg.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Bcfg.c @@ -1,7 +1,7 @@ /** @file
Main file for bcfg shell Debug1 function.
- Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -1027,12 +1027,14 @@ BcfgDisplayDumpDebug1( Buffer);
if (Status == EFI_BUFFER_TOO_SMALL) {
Buffer = AllocateZeroPool(BufferSize);
- Status = gRT->GetVariable(
- VariableName,
- (EFI_GUID*)&gEfiGlobalVariableGuid,
- NULL,
- &BufferSize,
- Buffer);
+ if (Buffer != NULL) {
+ Status = gRT->GetVariable(
+ VariableName,
+ (EFI_GUID*)&gEfiGlobalVariableGuid,
+ NULL,
+ &BufferSize,
+ Buffer);
+ }
}
if (EFI_ERROR(Status) || Buffer == NULL) {
@@ -1042,8 +1044,12 @@ BcfgDisplayDumpDebug1( if ((*(UINT16*)(Buffer+4)) != 0) {
DevPath = AllocateZeroPool(*(UINT16*)(Buffer+4));
- CopyMem(DevPath, Buffer+6+StrSize((CHAR16*)(Buffer+6)), *(UINT16*)(Buffer+4));
- DevPathString = ConvertDevicePathToText(DevPath, TRUE, FALSE);
+ if (DevPath != NULL) {
+ CopyMem(DevPath, Buffer+6+StrSize((CHAR16*)(Buffer+6)), *(UINT16*)(Buffer+4));
+ DevPathString = ConvertDevicePathToText(DevPath, TRUE, FALSE);
+ } else {
+ DevPathString = NULL;
+ }
} else {
DevPath = NULL;
DevPathString = NULL;
@@ -1213,12 +1219,16 @@ ShellCommandRunBcfg ( CurrentOperation.Order);
if (Status == EFI_BUFFER_TOO_SMALL) {
CurrentOperation.Order = AllocateZeroPool(Length+(4*sizeof(CurrentOperation.Order[0])));
- Status = gRT->GetVariable(
- CurrentOperation.Target == BcfgTargetBootOrder?(CHAR16*)L"BootOrder":(CHAR16*)L"DriverOrder",
- (EFI_GUID*)&gEfiGlobalVariableGuid,
- NULL,
- &Length,
- CurrentOperation.Order);
+ if (CurrentOperation.Order != NULL) {
+ Status = gRT->GetVariable(
+ CurrentOperation.Target == BcfgTargetBootOrder?(CHAR16*)L"BootOrder":(CHAR16*)L"DriverOrder",
+ (EFI_GUID*)&gEfiGlobalVariableGuid,
+ NULL,
+ &Length,
+ CurrentOperation.Order);
+ } else {
+ ShellStatus = SHELL_OUT_OF_RESOURCES;
+ }
}
}
|