]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/CapsuleApp: Fix potential NULL pointer dereference issue
authorChen A Chen <chen.a.chen@intel.com>
Fri, 1 Feb 2019 02:06:49 +0000 (10:06 +0800)
committerLiming Gao <liming.gao@intel.com>
Sat, 2 Feb 2019 13:41:20 +0000 (21:41 +0800)
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>
MdeModulePkg/Application/CapsuleApp/CapsuleApp.c
MdeModulePkg/Application/CapsuleApp/CapsuleDump.c
MdeModulePkg/Application/CapsuleApp/CapsuleOnDisk.c

index 896acd3304c90e11b8fdac33c1cd0d5aa51c91df..198a63555d2d32d62984741e02cb705957c88e18 100644 (file)
@@ -916,8 +916,9 @@ UefiMain (
   EFI_GUID                      ImageTypeId;\r
   UINTN                         ImageIndex;\r
 \r
   EFI_GUID                      ImageTypeId;\r
   UINTN                         ImageIndex;\r
 \r
-  MapFsStr = NULL;\r
-  CapsuleNum = 0;\r
+  BlockDescriptors  = NULL;\r
+  MapFsStr          = NULL;\r
+  CapsuleNum        = 0;\r
 \r
   Status = GetArg();\r
   if (EFI_ERROR(Status)) {\r
 \r
   Status = GetArg();\r
   if (EFI_ERROR(Status)) {\r
index 5bf617c5f62f1dca6fec5a491af44e1dc933cf74..7bef5a1378d4851f935c092670b3d54beacd4f93 100644 (file)
@@ -795,11 +795,13 @@ DumpCapsuleFromDisk (
   UINTN                                         FileCount;\r
   BOOLEAN                                       NoFile;\r
 \r
   UINTN                                         FileCount;\r
   BOOLEAN                                       NoFile;\r
 \r
-  DirHandle  = NULL;\r
-  FileHandle = NULL;\r
-  Index      = 0;\r
-  FileCount  = 0;\r
-  NoFile     = FALSE;\r
+  DirHandle       = NULL;\r
+  FileHandle      = NULL;\r
+  Index           = 0;\r
+  FileInfoBuffer  = NULL;\r
+  FileInfo        = NULL;\r
+  FileCount       = 0;\r
+  NoFile          = FALSE;\r
 \r
   Status = Fs->OpenVolume (Fs, &Root);\r
   if (EFI_ERROR (Status)) {\r
 \r
   Status = Fs->OpenVolume (Fs, &Root);\r
   if (EFI_ERROR (Status)) {\r
@@ -970,7 +972,10 @@ DumpProvisionedCapsule (
 \r
   ShellProtocol = GetShellProtocol ();\r
 \r
 \r
   ShellProtocol = GetShellProtocol ();\r
 \r
-  Index = 0;\r
+  Index             = 0;\r
+  CapsuleDataPtr64  = NULL;\r
+  BootNext          = NULL;\r
+  ShellProtocol     = NULL;\r
 \r
   //\r
   // Dump capsule provisioned on Memory\r
 \r
   //\r
   // Dump capsule provisioned on Memory\r
index 393b7ae7db4158a9bdca80120c8d6b735f96d139..4faa863bcaf02be37d289968278d6224a4b7b732 100644 (file)
@@ -151,9 +151,14 @@ DumpAllEfiSysPartition (
   UINTN                      NumberEfiSystemPartitions;\r
   EFI_SHELL_PROTOCOL         *ShellProtocol;\r
 \r
   UINTN                      NumberEfiSystemPartitions;\r
   EFI_SHELL_PROTOCOL         *ShellProtocol;\r
 \r
-  ShellProtocol = GetShellProtocol ();\r
   NumberEfiSystemPartitions = 0;\r
 \r
   NumberEfiSystemPartitions = 0;\r
 \r
+  ShellProtocol = GetShellProtocol ();\r
+  if (ShellProtocol == NULL) {\r
+    Print (L"Get Shell Protocol Fail\n");;\r
+    return ;\r
+  }\r
+\r
   Print (L"EFI System Partition list:\n");\r
 \r
   gBS->LocateHandleBuffer (\r
   Print (L"EFI System Partition list:\n");\r
 \r
   gBS->LocateHandleBuffer (\r
@@ -421,7 +426,13 @@ GetUpdateFileSystem (
   EFI_BOOT_MANAGER_LOAD_OPTION    NewOption;\r
 \r
   MappedDevicePath = NULL;\r
   EFI_BOOT_MANAGER_LOAD_OPTION    NewOption;\r
 \r
   MappedDevicePath = NULL;\r
+  BootOptionBuffer = NULL;\r
+\r
   ShellProtocol = GetShellProtocol ();\r
   ShellProtocol = GetShellProtocol ();\r
+  if (ShellProtocol == NULL) {\r
+    Print (L"Get Shell Protocol Fail\n");;\r
+    return EFI_NOT_FOUND;\r
+  }\r
 \r
   //\r
   // 1. If Fs is not assigned and there are capsule provisioned before,\r
 \r
   //\r
   // 1. If Fs is not assigned and there are capsule provisioned before,\r
@@ -468,7 +479,9 @@ GetUpdateFileSystem (
   // 2. Get EFI system partition form boot options.\r
   //\r
   BootOptionBuffer = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);\r
   // 2. Get EFI system partition form boot options.\r
   //\r
   BootOptionBuffer = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);\r
-  if (BootOptionCount == 0 && Map == NULL) {\r
+  if ( (BootOptionBuffer == NULL) ||\r
+       (BootOptionCount == 0 && Map == NULL)\r
+     ) {\r
     return EFI_NOT_FOUND;\r
   }\r
 \r
     return EFI_NOT_FOUND;\r
   }\r
 \r