public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] SecurityPkg TPM2: Assign real copied count in CopyDigestListToBuffer()
@ 2016-11-16 13:57 Star Zeng
  2016-11-17  3:18 ` Zhang, Chao B
  0 siblings, 1 reply; 3+ messages in thread
From: Star Zeng @ 2016-11-16 13:57 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng, Jiewen Yao, Chao Zhang

In CopyDigestListToBuffer() of Tpm2CommandLib, the count in returned
Buffer should be real copied DigestList count.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Chao Zhang <chao.b.zhang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
---
 SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
index 43574a246829..caa370c94381 100644
--- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
@@ -230,8 +230,10 @@ CopyDigestListToBuffer (
 {
   UINTN  Index;
   UINT16 DigestSize;
+  UINT32 *DigestListCount;
 
-  CopyMem (Buffer, &DigestList->count, sizeof(DigestList->count));
+  DigestListCount = (UINT32 *) Buffer;
+  *DigestListCount = 0;
   Buffer = (UINT8 *)Buffer + sizeof(DigestList->count);
   for (Index = 0; Index < DigestList->count; Index++) {
     if (!IsHashAlgSupportedInHashAlgorithmMask(DigestList->digests[Index].hashAlg, HashAlgorithmMask)) {
@@ -243,6 +245,7 @@ CopyDigestListToBuffer (
     DigestSize = GetHashSizeFromAlgo (DigestList->digests[Index].hashAlg);
     CopyMem (Buffer, &DigestList->digests[Index].digest, DigestSize);
     Buffer = (UINT8 *)Buffer + DigestSize;
+    (*DigestListCount)++;
   }
 
   return Buffer;
-- 
2.7.0.windows.1



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

end of thread, other threads:[~2016-11-17  8:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-16 13:57 [PATCH] SecurityPkg TPM2: Assign real copied count in CopyDigestListToBuffer() Star Zeng
2016-11-17  3:18 ` Zhang, Chao B
2016-11-17  8:06   ` Zeng, Star

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