summaryrefslogtreecommitdiffstats
path: root/SecurityPkg
diff options
context:
space:
mode:
authorStar Zeng <star.zeng@intel.com>2016-11-16 17:17:36 +0800
committerStar Zeng <star.zeng@intel.com>2016-11-21 10:38:29 +0800
commitbe93a17bbd1e8dd83904653aec17728641d67048 (patch)
tree71026556d7210024f47bd3002a32d3cc44725ed9 /SecurityPkg
parent6a62309459e36d59e4cfe14885fa3ed807841c62 (diff)
downloadedk2-be93a17bbd1e8dd83904653aec17728641d67048.tar.gz
edk2-be93a17bbd1e8dd83904653aec17728641d67048.tar.bz2
edk2-be93a17bbd1e8dd83904653aec17728641d67048.zip
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.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>
Diffstat (limited to 'SecurityPkg')
-rw-r--r--SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
index 43574a2468..be95fd69b3 100644
--- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
@@ -230,8 +230,11 @@ CopyDigestListToBuffer (
{
UINTN Index;
UINT16 DigestSize;
+ UINT32 DigestListCount;
+ UINT32 *DigestListCountPtr;
- CopyMem (Buffer, &DigestList->count, sizeof(DigestList->count));
+ DigestListCountPtr = (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,7 +246,9 @@ CopyDigestListToBuffer (
DigestSize = GetHashSizeFromAlgo (DigestList->digests[Index].hashAlg);
CopyMem (Buffer, &DigestList->digests[Index].digest, DigestSize);
Buffer = (UINT8 *)Buffer + DigestSize;
+ DigestListCount++;
}
+ WriteUnaligned32 (DigestListCountPtr, DigestListCount);
return Buffer;
}