]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
SecurityPkg TPM2: Assign real copied count in CopyDigestListToBuffer()
[mirror_edk2.git] / SecurityPkg / Library / Tpm2CommandLib / Tpm2Help.c
index 43574a24682905824f15c2c60263c46ebe72d572..be95fd69b3dd29be82553633579cd7e7eec284fb 100644 (file)
@@ -230,8 +230,11 @@ CopyDigestListToBuffer (
 {\r
   UINTN  Index;\r
   UINT16 DigestSize;\r
+  UINT32 DigestListCount;\r
+  UINT32 *DigestListCountPtr;\r
 \r
-  CopyMem (Buffer, &DigestList->count, sizeof(DigestList->count));\r
+  DigestListCountPtr = (UINT32 *) Buffer;\r
+  DigestListCount = 0;\r
   Buffer = (UINT8 *)Buffer + sizeof(DigestList->count);\r
   for (Index = 0; Index < DigestList->count; Index++) {\r
     if (!IsHashAlgSupportedInHashAlgorithmMask(DigestList->digests[Index].hashAlg, HashAlgorithmMask)) {\r
@@ -243,7 +246,9 @@ CopyDigestListToBuffer (
     DigestSize = GetHashSizeFromAlgo (DigestList->digests[Index].hashAlg);\r
     CopyMem (Buffer, &DigestList->digests[Index].digest, DigestSize);\r
     Buffer = (UINT8 *)Buffer + DigestSize;\r
+    DigestListCount++;\r
   }\r
+  WriteUnaligned32 (DigestListCountPtr, DigestListCount);\r
 \r
   return Buffer;\r
 }\r