From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 CFA7E820A2 for ; Wed, 21 Dec 2016 21:48:01 -0800 (PST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP; 21 Dec 2016 21:48:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,386,1477983600"; d="scan'208";a="1075104985" Received: from jyao1-mobl.ccr.corp.intel.com ([10.239.193.137]) by orsmga001.jf.intel.com with ESMTP; 21 Dec 2016 21:48:00 -0800 From: Jiewen Yao To: edk2-devel@lists.01.org Cc: Feng Tian , Star Zeng Date: Thu, 22 Dec 2016 13:47:35 +0800 Message-Id: <1482385656-1144-2-git-send-email-jiewen.yao@intel.com> X-Mailer: git-send-email 2.7.4.windows.1 In-Reply-To: <1482385656-1144-1-git-send-email-jiewen.yao@intel.com> References: <1482385656-1144-1-git-send-email-jiewen.yao@intel.com> Subject: [PATCH 1/2] MdeModulePkg/CapsuleLib: Add NULL capsule name in record. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Dec 2016 05:48:02 -0000 According to UEFI spec, capsule report variable should include a null terminator for capsule name and capsule target, if they are not present. The reserved field is zeroed. Cc: Feng Tian Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiewen Yao --- MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c index 2546871..d34eb25 100644 --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c @@ -104,7 +104,7 @@ IsFmpCapsuleProcessed ( CapsuleResult = &mCapsuleResultVariableCache[Index].CapsuleResultHeader; if (CapsuleResult->VariableTotalSize >= sizeof(EFI_CAPSULE_RESULT_VARIABLE_HEADER)) { if (CompareGuid(&CapsuleResult->CapsuleGuid, &gEfiFmpCapsuleGuid)) { - if (CapsuleResult->VariableTotalSize >= sizeof(EFI_CAPSULE_RESULT_VARIABLE_HEADER) + sizeof(EFI_CAPSULE_RESULT_VARIABLE_FMP)) { + if (CapsuleResult->VariableTotalSize >= sizeof(EFI_CAPSULE_RESULT_VARIABLE_HEADER) + sizeof(EFI_CAPSULE_RESULT_VARIABLE_FMP) + sizeof(CHAR16) * 2) { CapsuleResultFmp = (EFI_CAPSULE_RESULT_VARIABLE_FMP *)(CapsuleResult + 1); if (CompareGuid(&CapsuleResultFmp->UpdateImageTypeId, &ImageHeader->UpdateImageTypeId) && (CapsuleResultFmp->UpdateImageIndex == ImageHeader->UpdateImageIndex) && @@ -256,6 +256,7 @@ RecordCapsuleStatusVariable ( EFI_STATUS Status; CapsuleResultVariable.VariableTotalSize = sizeof(CapsuleResultVariable); + CapsuleResultVariable.Reserved = 0; CopyGuid (&CapsuleResultVariable.CapsuleGuid, &CapsuleHeader->CapsuleGuid); ZeroMem(&CapsuleResultVariable.CapsuleProcessed, sizeof(CapsuleResultVariable.CapsuleProcessed)); gRT->GetTime(&CapsuleResultVariable.CapsuleProcessed, NULL); @@ -298,13 +299,17 @@ RecordFmpCapsuleStatusVariable ( UINT32 CapsuleResultVariableSize; CapsuleResultVariable = NULL; - CapsuleResultVariableSize = sizeof(EFI_CAPSULE_RESULT_VARIABLE_HEADER) + sizeof(EFI_CAPSULE_RESULT_VARIABLE_FMP); - CapsuleResultVariable = AllocatePool (CapsuleResultVariableSize); + // + // Allocate zero CHAR16 for CapsuleFileName and CapsuleTarget. + // + CapsuleResultVariableSize = sizeof(EFI_CAPSULE_RESULT_VARIABLE_HEADER) + sizeof(EFI_CAPSULE_RESULT_VARIABLE_FMP) + sizeof(CHAR16) * 2; + CapsuleResultVariable = AllocateZeroPool (CapsuleResultVariableSize); if (CapsuleResultVariable == NULL) { return EFI_OUT_OF_RESOURCES; } CapsuleResultVariableHeader = (VOID *)CapsuleResultVariable; CapsuleResultVariableHeader->VariableTotalSize = CapsuleResultVariableSize; + CapsuleResultVariableHeader->Reserved = 0; CopyGuid(&CapsuleResultVariableHeader->CapsuleGuid, &CapsuleHeader->CapsuleGuid); ZeroMem(&CapsuleResultVariableHeader->CapsuleProcessed, sizeof(CapsuleResultVariableHeader->CapsuleProcessed)); gRT->GetTime(&CapsuleResultVariableHeader->CapsuleProcessed, NULL); -- 2.7.4.windows.1