public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 0/2] Handle NULL capsule name in record.
@ 2016-12-22  5:47 Jiewen Yao
  2016-12-22  5:47 ` [PATCH 1/2] MdeModulePkg/CapsuleLib: Add " Jiewen Yao
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Jiewen Yao @ 2016-12-22  5:47 UTC (permalink / raw)
  To: edk2-devel

According to UEFI spec, capsule report variable should include
a null terminator for capsule name and capsule target, if they are
not present.

Jiewen Yao (2):
  MdeModulePkg/CapsuleLib: Add NULL capsule name in record.
  MdeModulePkg/CapsuleApp: Dump capsule name in record.

 MdeModulePkg/Application/CapsuleApp/CapsuleDump.c           | 16 ++++++++--------
 MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c | 11 ++++++++---
 2 files changed, 16 insertions(+), 11 deletions(-)

-- 
2.7.4.windows.1



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] MdeModulePkg/CapsuleLib: Add NULL capsule name in record.
  2016-12-22  5:47 [PATCH 0/2] Handle NULL capsule name in record Jiewen Yao
@ 2016-12-22  5:47 ` Jiewen Yao
  2016-12-22  5:47 ` [PATCH 2/2] MdeModulePkg/CapsuleApp: Dump " Jiewen Yao
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Jiewen Yao @ 2016-12-22  5:47 UTC (permalink / raw)
  To: edk2-devel; +Cc: Feng Tian, Star Zeng

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



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] MdeModulePkg/CapsuleApp: Dump capsule name in record.
  2016-12-22  5:47 [PATCH 0/2] Handle NULL capsule name in record Jiewen Yao
  2016-12-22  5:47 ` [PATCH 1/2] MdeModulePkg/CapsuleLib: Add " Jiewen Yao
@ 2016-12-22  5:47 ` Jiewen Yao
  2016-12-23  1:14 ` [PATCH 0/2] Handle NULL " Tian, Feng
  2016-12-23  2:00 ` Zeng, Star
  3 siblings, 0 replies; 5+ messages in thread
From: Jiewen Yao @ 2016-12-22  5:47 UTC (permalink / raw)
  To: edk2-devel; +Cc: Feng Tian, Star Zeng

According to UEFI spec, capsule report variable should include
a null terminator for capsule name and capsule target, if they are
not present.

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/Application/CapsuleApp/CapsuleDump.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/MdeModulePkg/Application/CapsuleApp/CapsuleDump.c b/MdeModulePkg/Application/CapsuleApp/CapsuleDump.c
index 8f44e5e..2bb5f1f 100644
--- a/MdeModulePkg/Application/CapsuleApp/CapsuleDump.c
+++ b/MdeModulePkg/Application/CapsuleApp/CapsuleDump.c
@@ -293,6 +293,8 @@ DmpCapsuleStatusVariable (
   UINTN                               CapsuleFileNameSize;
   CHAR16                              CapsuleIndexData[12];
   CHAR16                              *CapsuleIndex;
+  CHAR16                              *CapsuleFileName;
+  CHAR16                              *CapsuleTarget;
 
   Status = GetVariable2(
              L"CapsuleMax",
@@ -353,19 +355,17 @@ DmpCapsuleStatusVariable (
     }
 
     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);
         Print(L"  Capsule FMP Version: 0x%x\n", CapsuleResultFmp->Version);
         Print(L"  Capsule FMP PayloadIndex: 0x%x\n", CapsuleResultFmp->PayloadIndex);
         Print(L"  Capsule FMP UpdateImageIndex: 0x%x\n", CapsuleResultFmp->UpdateImageIndex);
         Print(L"  Capsule FMP UpdateImageTypeId: %g\n", &CapsuleResultFmp->UpdateImageTypeId);
-        if (CapsuleResult->VariableTotalSize > sizeof(EFI_CAPSULE_RESULT_VARIABLE_HEADER) + sizeof(EFI_CAPSULE_RESULT_VARIABLE_FMP)) {
-          Print(L"  Capsule FMP CapsuleFileName: %s\n", (CapsuleResultFmp + 1));
-          CapsuleFileNameSize = StrSize((CHAR16 *)(CapsuleResultFmp + 1));
-          if (CapsuleResult->VariableTotalSize > sizeof(EFI_CAPSULE_RESULT_VARIABLE_HEADER) + sizeof(EFI_CAPSULE_RESULT_VARIABLE_FMP) + CapsuleFileNameSize) {
-            Print(L"  Capsule FMP CapsuleTarget: %s\n", (UINT8 *)(CapsuleResultFmp + 1) + CapsuleFileNameSize);
-          }
-        }
+        CapsuleFileName = (CHAR16 *)(CapsuleResultFmp + 1);
+        Print(L"  Capsule FMP CapsuleFileName: \"%s\"\n", CapsuleFileName);
+        CapsuleFileNameSize = StrSize(CapsuleFileName);
+        CapsuleTarget = (CHAR16 *)((UINTN)CapsuleFileName + CapsuleFileNameSize);
+        Print(L"  Capsule FMP CapsuleTarget: \"%s\"\n", CapsuleTarget);
       }
     }
 
-- 
2.7.4.windows.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2] Handle NULL capsule name in record.
  2016-12-22  5:47 [PATCH 0/2] Handle NULL capsule name in record Jiewen Yao
  2016-12-22  5:47 ` [PATCH 1/2] MdeModulePkg/CapsuleLib: Add " Jiewen Yao
  2016-12-22  5:47 ` [PATCH 2/2] MdeModulePkg/CapsuleApp: Dump " Jiewen Yao
@ 2016-12-23  1:14 ` Tian, Feng
  2016-12-23  2:00 ` Zeng, Star
  3 siblings, 0 replies; 5+ messages in thread
From: Tian, Feng @ 2016-12-23  1:14 UTC (permalink / raw)
  To: Yao, Jiewen, edk2-devel@lists.01.org; +Cc: Tian, Feng

Reviewed-by: Feng Tian <feng.tian@Intel.com>

Thanks
Feng

-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Jiewen Yao
Sent: Thursday, December 22, 2016 1:48 PM
To: edk2-devel@lists.01.org
Subject: [edk2] [PATCH 0/2] Handle NULL capsule name in record.

According to UEFI spec, capsule report variable should include a null terminator for capsule name and capsule target, if they are not present.

Jiewen Yao (2):
  MdeModulePkg/CapsuleLib: Add NULL capsule name in record.
  MdeModulePkg/CapsuleApp: Dump capsule name in record.

 MdeModulePkg/Application/CapsuleApp/CapsuleDump.c           | 16 ++++++++--------
 MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c | 11 ++++++++---
 2 files changed, 16 insertions(+), 11 deletions(-)

--
2.7.4.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2] Handle NULL capsule name in record.
  2016-12-22  5:47 [PATCH 0/2] Handle NULL capsule name in record Jiewen Yao
                   ` (2 preceding siblings ...)
  2016-12-23  1:14 ` [PATCH 0/2] Handle NULL " Tian, Feng
@ 2016-12-23  2:00 ` Zeng, Star
  3 siblings, 0 replies; 5+ messages in thread
From: Zeng, Star @ 2016-12-23  2:00 UTC (permalink / raw)
  To: Yao, Jiewen, edk2-devel@lists.01.org; +Cc: Zeng, Star

Reviewed-by: Star Zeng <star.zeng@intel.com>

-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Jiewen Yao
Sent: Thursday, December 22, 2016 1:48 PM
To: edk2-devel@lists.01.org
Subject: [edk2] [PATCH 0/2] Handle NULL capsule name in record.

According to UEFI spec, capsule report variable should include a null terminator for capsule name and capsule target, if they are not present.

Jiewen Yao (2):
  MdeModulePkg/CapsuleLib: Add NULL capsule name in record.
  MdeModulePkg/CapsuleApp: Dump capsule name in record.

 MdeModulePkg/Application/CapsuleApp/CapsuleDump.c           | 16 ++++++++--------
 MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c | 11 ++++++++---
 2 files changed, 16 insertions(+), 11 deletions(-)

--
2.7.4.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-12-23  2:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-22  5:47 [PATCH 0/2] Handle NULL capsule name in record Jiewen Yao
2016-12-22  5:47 ` [PATCH 1/2] MdeModulePkg/CapsuleLib: Add " Jiewen Yao
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox