From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web12.6199.1631260895965185484 for ; Fri, 10 Sep 2021 01:01:38 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.43, mailfrom: dun.tan@intel.com) X-IronPort-AV: E=McAfee;i="6200,9189,10102"; a="306587655" X-IronPort-AV: E=Sophos;i="5.85,282,1624345200"; d="scan'208";a="306587655" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Sep 2021 01:01:38 -0700 X-IronPort-AV: E=Sophos;i="5.85,282,1624345200"; d="scan'208";a="540338276" Received: from duntan-mobl.ccr.corp.intel.com ([10.238.1.156]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Sep 2021 01:01:36 -0700 From: "duntan" To: devel@edk2.groups.io Cc: duntan , Guo Dong , Ray Ni , Maurice Ma , Benjamin You , Zhiguang Liu Subject: [Patch V3 1/2] UefiPayloadPkg: Fix the bug in dump guid HOB info functions Date: Fri, 10 Sep 2021 16:01:10 +0800 Message-Id: <20210910080111.113-2-dun.tan@intel.com> X-Mailer: git-send-email 2.31.1.windows.1 In-Reply-To: <20210910080111.113-1-dun.tan@intel.com> References: <20210910080111.113-1-dun.tan@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: duntan The input HobLength of PrintHandler should be data size instead of whole length of HOB Cc: Guo Dong Reviewed-by: Ray Ni Cc: Maurice Ma Cc: Benjamin You Reviewed-by: Zhiguang Liu Signed-off-by: Dun Tan --- 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