Hi Star:
  Please use WtiteUnaligned32 to update hash count. Others are good to me.





Thanks & Best regards
Chao Zhang

-----Original Message-----
From: Zeng, Star 
Sent: Wednesday, November 16, 2016 9:58 PM
To: edk2-devel@lists.01.org
Cc: Zeng, Star; Yao, Jiewen; Zhang, Chao B
Subject: [PATCH] SecurityPkg TPM2: Assign real copied count in 
CopyDigestListToBuffer()

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

Cc: Jiewen Yao <jiewen....@intel.com>
Cc: Chao Zhang <chao.b.zh...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.z...@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

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to