diff options
author | Star Zeng <star.zeng@intel.com> | 2018-07-26 13:57:11 +0800 |
---|---|---|
committer | Star Zeng <star.zeng@intel.com> | 2018-07-27 16:04:12 +0800 |
commit | 83e1007838016fa049f73790ff085064d0672ad6 (patch) | |
tree | 3bf9b3718ec40e3fdca9f7aa74304ded43d3ac2e /MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c | |
parent | 1010873becc51edeab4637ccce9c52fa4e790f34 (diff) | |
download | edk2-83e1007838016fa049f73790ff085064d0672ad6.zip edk2-83e1007838016fa049f73790ff085064d0672ad6.tar.gz edk2-83e1007838016fa049f73790ff085064d0672ad6.tar.bz2 |
MdeModulePkg DxeCapsuleLibFmp: Refine the code to check FmpImageSize
The code to check FmpImageSize again OFFSET_OF
(EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER, UpdateHardwareInstance)
can be refined to check against FmpImageHeaderSize.
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>
Diffstat (limited to 'MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c')
-rw-r--r-- | MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c index a1347b5..ee3adce 100644 --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c @@ -268,10 +268,6 @@ ValidateFmpCapsule ( }
FmpImageSize = (UINTN)EndOfPayload - ItemOffsetList[Index];
- if (FmpImageSize < OFFSET_OF(EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER, UpdateHardwareInstance)) {
- DEBUG((DEBUG_ERROR, "FmpImageSize(0x%lx) < EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER\n", FmpImageSize));
- return EFI_INVALID_PARAMETER;
- }
FmpImageHeaderSize = sizeof(EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER);
if ((ImageHeader->Version > EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER_INIT_VERSION) ||
(ImageHeader->Version < 1)) {
@@ -281,6 +277,10 @@ ValidateFmpCapsule ( if (ImageHeader->Version < EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER_INIT_VERSION) {
FmpImageHeaderSize = OFFSET_OF(EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER, UpdateHardwareInstance);
}
+ if (FmpImageSize < FmpImageHeaderSize) {
+ DEBUG((DEBUG_ERROR, "FmpImageSize(0x%lx) < FmpImageHeaderSize(0x%x)\n", FmpImageSize, FmpImageHeaderSize));
+ return EFI_INVALID_PARAMETER;
+ }
// No overflow
if (FmpImageSize != (UINT64)FmpImageHeaderSize + (UINT64)ImageHeader->UpdateImageSize + (UINT64)ImageHeader->UpdateVendorCodeSize) {
|