From: Ruiyu Ni Date: Fri, 16 Mar 2018 07:04:05 +0000 (+0800) Subject: MdeModulePkg/DxeCapsuleLibFmp: Add more check for the UX capsule X-Git-Tag: edk2-stable201903~2105 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=d0976b9accedfd1f45fe2f81c59351ed17f34aa0 MdeModulePkg/DxeCapsuleLibFmp: Add more check for the UX capsule Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Reviewed-by: Jiewen Yao --- diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c index 15dbc00216..555c5971d0 100644 --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c @@ -330,8 +330,25 @@ DisplayCapsuleImage ( UINTN Width; EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput; - ImagePayload = (DISPLAY_DISPLAY_PAYLOAD *)(CapsuleHeader + 1); - PayloadSize = CapsuleHeader->CapsuleImageSize - sizeof(EFI_CAPSULE_HEADER); + // + // UX capsule doesn't have extended header entries. + // + if (CapsuleHeader->HeaderSize != sizeof (EFI_CAPSULE_HEADER)) { + return EFI_UNSUPPORTED; + } + ImagePayload = (DISPLAY_DISPLAY_PAYLOAD *)((UINTN) CapsuleHeader + CapsuleHeader->HeaderSize); + // + // (CapsuleImageSize > HeaderSize) is guaranteed by IsValidCapsuleHeader(). + // + PayloadSize = CapsuleHeader->CapsuleImageSize - CapsuleHeader->HeaderSize; + + // + // Make sure the image payload at least contain the DISPLAY_DISPLAY_PAYLOAD header. + // Further size check is performed by the logic translating BMP to GOP BLT. + // + if (PayloadSize <= sizeof (DISPLAY_DISPLAY_PAYLOAD)) { + return EFI_INVALID_PARAMETER; + } if (ImagePayload->Version != 1) { return EFI_UNSUPPORTED;