UefiPayloadPkg: Fix the bug in dump guid HOB info functions

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

Cc: Guo Dong <guo.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Reviewed-by: Zhiguang Liu <zhiguang.liu@intel.com>
Signed-off-by: Dun Tan <dun.tan@intel.com>
This commit is contained in:
duntan 2021-09-10 16:01:10 +08:00 committed by mergify[bot]
parent cf7c650592
commit d96df7e993
1 changed files with 7 additions and 3 deletions

View File

@ -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;
}
}