summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Application
diff options
context:
space:
mode:
authorChen A Chen <chen.a.chen@intel.com>2019-02-01 10:06:49 +0800
committerLiming Gao <liming.gao@intel.com>2019-02-02 21:41:20 +0800
commite98212cb5d59fff8f385d9179ad7f1a3ce9cf215 (patch)
treeab4f7daeb28fc5c89e82faab5fa7c738fdb03e5f /MdeModulePkg/Application
parentaad4e2ec8ffe2aae6bdcdd04f34a1d3b0bf2c4a9 (diff)
downloadedk2-e98212cb5d59fff8f385d9179ad7f1a3ce9cf215.tar.gz
edk2-e98212cb5d59fff8f385d9179ad7f1a3ce9cf215.tar.bz2
edk2-e98212cb5d59fff8f385d9179ad7f1a3ce9cf215.zip
MdeModulePkg/CapsuleApp: Fix potential NULL pointer dereference issue
To avoid potential NULL pointer dereference issue. Initialize them at the beginning of the function. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao Wu <hao.a.wu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Chen A Chen <chen.a.chen@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
Diffstat (limited to 'MdeModulePkg/Application')
-rw-r--r--MdeModulePkg/Application/CapsuleApp/CapsuleApp.c5
-rw-r--r--MdeModulePkg/Application/CapsuleApp/CapsuleDump.c17
-rw-r--r--MdeModulePkg/Application/CapsuleApp/CapsuleOnDisk.c17
3 files changed, 29 insertions, 10 deletions
diff --git a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c b/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c
index 896acd3304..198a63555d 100644
--- a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c
+++ b/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c
@@ -916,8 +916,9 @@ UefiMain (
EFI_GUID ImageTypeId;
UINTN ImageIndex;
- MapFsStr = NULL;
- CapsuleNum = 0;
+ BlockDescriptors = NULL;
+ MapFsStr = NULL;
+ CapsuleNum = 0;
Status = GetArg();
if (EFI_ERROR(Status)) {
diff --git a/MdeModulePkg/Application/CapsuleApp/CapsuleDump.c b/MdeModulePkg/Application/CapsuleApp/CapsuleDump.c
index 5bf617c5f6..7bef5a1378 100644
--- a/MdeModulePkg/Application/CapsuleApp/CapsuleDump.c
+++ b/MdeModulePkg/Application/CapsuleApp/CapsuleDump.c
@@ -795,11 +795,13 @@ DumpCapsuleFromDisk (
UINTN FileCount;
BOOLEAN NoFile;
- DirHandle = NULL;
- FileHandle = NULL;
- Index = 0;
- FileCount = 0;
- NoFile = FALSE;
+ DirHandle = NULL;
+ FileHandle = NULL;
+ Index = 0;
+ FileInfoBuffer = NULL;
+ FileInfo = NULL;
+ FileCount = 0;
+ NoFile = FALSE;
Status = Fs->OpenVolume (Fs, &Root);
if (EFI_ERROR (Status)) {
@@ -970,7 +972,10 @@ DumpProvisionedCapsule (
ShellProtocol = GetShellProtocol ();
- Index = 0;
+ Index = 0;
+ CapsuleDataPtr64 = NULL;
+ BootNext = NULL;
+ ShellProtocol = NULL;
//
// Dump capsule provisioned on Memory
diff --git a/MdeModulePkg/Application/CapsuleApp/CapsuleOnDisk.c b/MdeModulePkg/Application/CapsuleApp/CapsuleOnDisk.c
index 393b7ae7db..4faa863bca 100644
--- a/MdeModulePkg/Application/CapsuleApp/CapsuleOnDisk.c
+++ b/MdeModulePkg/Application/CapsuleApp/CapsuleOnDisk.c
@@ -151,9 +151,14 @@ DumpAllEfiSysPartition (
UINTN NumberEfiSystemPartitions;
EFI_SHELL_PROTOCOL *ShellProtocol;
- ShellProtocol = GetShellProtocol ();
NumberEfiSystemPartitions = 0;
+ ShellProtocol = GetShellProtocol ();
+ if (ShellProtocol == NULL) {
+ Print (L"Get Shell Protocol Fail\n");;
+ return ;
+ }
+
Print (L"EFI System Partition list:\n");
gBS->LocateHandleBuffer (
@@ -421,7 +426,13 @@ GetUpdateFileSystem (
EFI_BOOT_MANAGER_LOAD_OPTION NewOption;
MappedDevicePath = NULL;
+ BootOptionBuffer = NULL;
+
ShellProtocol = GetShellProtocol ();
+ if (ShellProtocol == NULL) {
+ Print (L"Get Shell Protocol Fail\n");;
+ return EFI_NOT_FOUND;
+ }
//
// 1. If Fs is not assigned and there are capsule provisioned before,
@@ -468,7 +479,9 @@ GetUpdateFileSystem (
// 2. Get EFI system partition form boot options.
//
BootOptionBuffer = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);
- if (BootOptionCount == 0 && Map == NULL) {
+ if ( (BootOptionBuffer == NULL) ||
+ (BootOptionCount == 0 && Map == NULL)
+ ) {
return EFI_NOT_FOUND;
}