mirror of https://github.com/acidanthera/audk.git
MdeModulePkg CapsuleApp: Check Buffer against NULL before freeing it
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>
This commit is contained in:
parent
053cd183c9
commit
2e3032b4aa
|
@ -1,7 +1,7 @@
|
||||||
/** @file
|
/** @file
|
||||||
Dump Capsule image information.
|
Dump Capsule image information.
|
||||||
|
|
||||||
Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -242,6 +242,7 @@ DumpCapsule (
|
||||||
EFI_CAPSULE_HEADER *CapsuleHeader;
|
EFI_CAPSULE_HEADER *CapsuleHeader;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
Buffer = NULL;
|
||||||
Status = ReadFileToBuffer(CapsuleName, &FileSize, &Buffer);
|
Status = ReadFileToBuffer(CapsuleName, &FileSize, &Buffer);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR(Status)) {
|
||||||
Print(L"CapsuleApp: Capsule (%s) is not found.\n", CapsuleName);
|
Print(L"CapsuleApp: Capsule (%s) is not found.\n", CapsuleName);
|
||||||
|
@ -269,7 +270,9 @@ DumpCapsule (
|
||||||
}
|
}
|
||||||
|
|
||||||
Done:
|
Done:
|
||||||
|
if (Buffer != NULL) {
|
||||||
FreePool(Buffer);
|
FreePool(Buffer);
|
||||||
|
}
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue