From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.88; helo=mga01.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id C8A3422489C89 for ; Thu, 15 Mar 2018 23:59:20 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Mar 2018 00:05:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,313,1517904000"; d="scan'208";a="183301752" Received: from ray-dev.ccr.corp.intel.com ([10.239.9.4]) by orsmga004.jf.intel.com with ESMTP; 16 Mar 2018 00:05:44 -0700 From: Ruiyu Ni To: edk2-devel@lists.01.org Cc: Jiewen Yao Date: Fri, 16 Mar 2018 15:05:43 +0800 Message-Id: <20180316070543.357716-1-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.16.1.windows.1 Subject: [PATCH] MdeModulePkg/DxeCapsuleLibFmp: Add more check for the UX capsule X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Mar 2018 06:59:21 -0000 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Jiewen Yao --- .../Library/DxeCapsuleLibFmp/DxeCapsuleLib.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) 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; -- 2.16.1.windows.1