]> git.proxmox.com Git - mirror_edk2.git/commitdiff
SecurityPkg TPM2: Assign real copied count in CopyDigestListToBuffer()
authorStar Zeng <star.zeng@intel.com>
Wed, 16 Nov 2016 09:17:36 +0000 (17:17 +0800)
committerStar Zeng <star.zeng@intel.com>
Mon, 21 Nov 2016 02:38:29 +0000 (10:38 +0800)
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>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
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