public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "duntan" <dun.tan@intel.com>
To: devel@edk2.groups.io
Cc: Guo Dong <guo.dong@intel.com>, Ray Ni <ray.ni@intel.com>,
	Maurice Ma <maurice.ma@intel.com>,
	Benjamin You <benjamin.you@intel.com>,
	Zhiguang Liu <zhiguang.liu@intel.com>, DunTan <dun.tan@intel.com>
Subject: [Patch V2 1/2] UefiPayloadPkg: Fix the bug in dump guid HOB info functions
Date: Tue, 31 Aug 2021 13:38:15 +0800	[thread overview]
Message-ID: <20210831053816.2366-2-dun.tan@intel.com> (raw)
In-Reply-To: <20210831053816.2366-1-dun.tan@intel.com>

The input HobLength of PrintHandler should be data size instead of whole length of HOB

Cc: Guo Dong <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Signed-off-by: DunTan <dun.tan@intel.com>
---
 UefiPayloadPkg/UefiPayloadEntry/PrintHob.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/UefiPayloadPkg/UefiPayloadEntry/PrintHob.c b/UefiPayloadPkg/UefiPayloadEntry/PrintHob.c
index 5fb638d4a4..f93aeec472 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/PrintHob.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/PrintHob.c
@@ -317,9 +317,11 @@ PrintPciRootBridgeInfoGuidHob (
 {
   UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *PciRootBridges;
   UINTN                              Index;
+  UINTN                              Length;
   Index = 0;
   PciRootBridges = (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *) GET_GUID_HOB_DATA (HobRaw);
-  ASSERT (HobLength >= sizeof (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES));
+  Length = sizeof (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES) + PciRootBridges->Count * sizeof (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE);
+  ASSERT (HobLength >= Length);
   DEBUG ((DEBUG_INFO, "   Revision         = 0x%x\n", PciRootBridges->Header.Revision));
   DEBUG ((DEBUG_INFO, "   Length           = 0x%x\n", PciRootBridges->Header.Length));
   DEBUG ((DEBUG_INFO, "   Count            = 0x%x\n", PciRootBridges->Count));
@@ -369,10 +371,12 @@ PrintExtraDataGuidHob (
 {
   UNIVERSAL_PAYLOAD_EXTRA_DATA *ExtraData;
   UINTN                        Index;
+  UINTN                        Length;
 
   Index     = 0;
   ExtraData = (UNIVERSAL_PAYLOAD_EXTRA_DATA *) GET_GUID_HOB_DATA (HobRaw);
-  ASSERT (HobLength >= ExtraData->Header.Length);
+  Length = sizeof (UNIVERSAL_PAYLOAD_EXTRA_DATA) + ExtraData->Count * sizeof (UNIVERSAL_PAYLOAD_EXTRA_DATA_ENTRY);
+  ASSERT (HobLength >= Length);
   DEBUG ((DEBUG_INFO, "   Revision  = 0x%x\n", ExtraData->Header.Revision));
   DEBUG ((DEBUG_INFO, "   Length    = 0x%x\n", ExtraData->Header.Length));
   DEBUG ((DEBUG_INFO, "   Count     = 0x%x\n", ExtraData->Count));
@@ -443,7 +447,7 @@ PrintGuidHob (
   for (Index = 0; Index < ARRAY_SIZE (GuidHobPrintHandleTable); Index++) {
     if (CompareGuid (&Hob.Guid->Name, GuidHobPrintHandleTable[Index].Guid)) {
       DEBUG ((DEBUG_INFO, "   Guid   = %a\n", GuidHobPrintHandleTable[Index].GuidName));
-      Status = GuidHobPrintHandleTable[Index].PrintHandler (Hob.Raw, Hob.Header->HobLength);
+      Status = GuidHobPrintHandleTable[Index].PrintHandler (Hob.Raw, GET_GUID_HOB_DATA_SIZE (Hob.Raw));
       return Status;
     }
   }
-- 
2.31.1.windows.1


  reply	other threads:[~2021-08-31  5:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-31  5:38 [Patch V2 0/2] Fix bug in dump guid HOB info funcs and dump info from a new GUID HOB duntan
2021-08-31  5:38 ` duntan [this message]
2021-09-09  1:58   ` [Patch V2 1/2] UefiPayloadPkg: Fix the bug in dump guid HOB info functions Zhiguang Liu
2021-09-09 12:22   ` Ni, Ray
2021-08-31  5:38 ` [Patch V2 2/2] UefiPayloadPkg: Dump hob info from gEdkiiBootManagerMenuFileGuid duntan
2021-09-09  1:59   ` [edk2-devel] " Zhiguang Liu
2021-09-09 12:22   ` Ni, Ray

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=20210831053816.2366-2-dun.tan@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