public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Jiewen Yao <jiewen.yao@intel.com>
To: edk2-devel@lists.01.org
Cc: Feng Tian <feng.tian@intel.com>, Star Zeng <star.zeng@intel.com>
Subject: [PATCH 1/2] MdeModulePkg/CapsuleLib: Add NULL capsule name in record.
Date: Thu, 22 Dec 2016 13:47:35 +0800	[thread overview]
Message-ID: <1482385656-1144-2-git-send-email-jiewen.yao@intel.com> (raw)
In-Reply-To: <1482385656-1144-1-git-send-email-jiewen.yao@intel.com>

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 <feng.tian@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
---
 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



  reply	other threads:[~2016-12-22  5:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-22  5:47 [PATCH 0/2] Handle NULL capsule name in record Jiewen Yao
2016-12-22  5:47 ` Jiewen Yao [this message]
2016-12-22  5:47 ` [PATCH 2/2] MdeModulePkg/CapsuleApp: Dump " Jiewen Yao
2016-12-23  1:14 ` [PATCH 0/2] Handle NULL " Tian, Feng
2016-12-23  2:00 ` Zeng, Star

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1482385656-1144-2-git-send-email-jiewen.yao@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox