[edk2-platforms][PATCH v2 2/5] MinPlatformPkg/TestPointCheckLib: Set required size field in protocol


Michael Kubacki
 

From: Michael Kubacki <michael.kubacki@microsoft.com>

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D3518

Per the protocol definition, the caller must allocate the input
structure and set the size field. TestPointCheckTcgTrustedBoot()
does not do this which can result in an EFI_BUFFER_TOO_SMALL error.

Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Eric Dong <eric.dong@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
---
Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckTcg=
TrustedBoot.c | 3 +++
Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeTestPoin=
tCheckLib.inf | 1 +
2 files changed, 4 insertions(+)

diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib=
/DxeCheckTcgTrustedBoot.c b/Platform/Intel/MinPlatformPkg/Test/Library/Te=
stPointCheckLib/DxeCheckTcgTrustedBoot.c
index 2a04f86fedac..5ec32fd2e875 100644
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeChe=
ckTcgTrustedBoot.c
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeChe=
ckTcgTrustedBoot.c
@@ -9,6 +9,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <PiDxe.h>
#include <Library/TestPointCheckLib.h>
#include <Library/TestPointLib.h>
+#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/UefiLib.h>
#include <Library/PrintLib.h>
@@ -41,6 +42,8 @@ TestPointCheckTcgTrustedBoot (
goto Done;
}
=20
+ ZeroMem ((VOID *) &ProtocolCapability, sizeof (ProtocolCapability));
+ ProtocolCapability.Size =3D (UINT8) sizeof (ProtocolCapability);
Status =3D Tcg2->GetCapability (Tcg2, &ProtocolCapability);
if (EFI_ERROR(Status)) {
DEBUG ((DEBUG_ERROR, "Tcg2->GetCapability - %r\n", Status));
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib=
/DxeTestPointCheckLib.inf b/Platform/Intel/MinPlatformPkg/Test/Library/Te=
stPointCheckLib/DxeTestPointCheckLib.inf
index 54b4015d6767..195729e0ff5b 100644
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeTes=
tPointCheckLib.inf
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeTes=
tPointCheckLib.inf
@@ -18,6 +18,7 @@ [Defines]
=20
[LibraryClasses]
BaseLib
+ BaseMemoryLib
DebugLib
DxeServicesTableLib
UefiBootServicesTableLib
--=20
2.28.0.windows.1

Join devel@edk2.groups.io to automatically receive all group messages.