]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg CapsuleApp: Check Buffer against NULL before freeing it
authorStar Zeng <star.zeng@intel.com>
Thu, 26 Apr 2018 09:16:47 +0000 (17:16 +0800)
committerStar Zeng <star.zeng@intel.com>
Tue, 8 May 2018 03:16:49 +0000 (11:16 +0800)
If the capsule from command line is not present,
Buffer will be random value when freeing it in DumpCapsule(),
then ASSERT will happen or other memory pool may be freed.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
MdeModulePkg/Application/CapsuleApp/CapsuleDump.c

index 2bb5f1f02cf427888055b285afe84c38709f67b5..6c1320942bf423929e5cc6c67c9f66d12e5e8639 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Dump Capsule image information.\r
 \r
-  Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -242,6 +242,7 @@ DumpCapsule (
   EFI_CAPSULE_HEADER                            *CapsuleHeader;\r
   EFI_STATUS                                    Status;\r
 \r
+  Buffer = NULL;\r
   Status = ReadFileToBuffer(CapsuleName, &FileSize, &Buffer);\r
   if (EFI_ERROR(Status)) {\r
     Print(L"CapsuleApp: Capsule (%s) is not found.\n", CapsuleName);\r
@@ -269,7 +270,9 @@ DumpCapsule (
   }\r
 \r
 Done:\r
-  FreePool(Buffer);\r
+  if (Buffer != NULL) {\r
+    FreePool(Buffer);\r
+  }\r
   return Status;\r
 }\r
 \r