MdeModulePkg CapsuleApp: Check capsule header for -D and -N options
Then meaningful error message can be shown when the input image is unexpected. Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@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:
@@ -61,6 +61,24 @@ WriteFileFromBuffer (
|
||||
IN VOID *Buffer
|
||||
);
|
||||
|
||||
/**
|
||||
Validate if it is valid capsule header
|
||||
|
||||
This function assumes the caller provided correct CapsuleHeader pointer
|
||||
and CapsuleSize.
|
||||
|
||||
This function validates the fields in EFI_CAPSULE_HEADER.
|
||||
|
||||
@param[in] CapsuleHeader Points to a capsule header.
|
||||
@param[in] CapsuleSize Size of the whole capsule image.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
IsValidCapsuleHeader (
|
||||
IN EFI_CAPSULE_HEADER *CapsuleHeader,
|
||||
IN UINT64 CapsuleSize
|
||||
);
|
||||
|
||||
/**
|
||||
Dump UX capsule information.
|
||||
|
||||
@@ -248,6 +266,11 @@ DumpCapsule (
|
||||
Print(L"CapsuleApp: Capsule (%s) is not found.\n", CapsuleName);
|
||||
goto Done;
|
||||
}
|
||||
if (!IsValidCapsuleHeader (Buffer, FileSize)) {
|
||||
Print(L"CapsuleApp: Capsule image (%s) is not a valid capsule.\n", CapsuleName);
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
CapsuleHeader = Buffer;
|
||||
if (CompareGuid(&CapsuleHeader->CapsuleGuid, &gWindowsUxCapsuleGuid)) {
|
||||
|
Reference in New Issue
Block a user