mirror of https://github.com/acidanthera/audk.git
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>
This commit is contained in:
parent
6a62309459
commit
be93a17bbd
|
@ -230,8 +230,11 @@ CopyDigestListToBuffer (
|
||||||
{
|
{
|
||||||
UINTN Index;
|
UINTN Index;
|
||||||
UINT16 DigestSize;
|
UINT16 DigestSize;
|
||||||
|
UINT32 DigestListCount;
|
||||||
|
UINT32 *DigestListCountPtr;
|
||||||
|
|
||||||
CopyMem (Buffer, &DigestList->count, sizeof(DigestList->count));
|
DigestListCountPtr = (UINT32 *) Buffer;
|
||||||
|
DigestListCount = 0;
|
||||||
Buffer = (UINT8 *)Buffer + sizeof(DigestList->count);
|
Buffer = (UINT8 *)Buffer + sizeof(DigestList->count);
|
||||||
for (Index = 0; Index < DigestList->count; Index++) {
|
for (Index = 0; Index < DigestList->count; Index++) {
|
||||||
if (!IsHashAlgSupportedInHashAlgorithmMask(DigestList->digests[Index].hashAlg, HashAlgorithmMask)) {
|
if (!IsHashAlgSupportedInHashAlgorithmMask(DigestList->digests[Index].hashAlg, HashAlgorithmMask)) {
|
||||||
|
@ -243,7 +246,9 @@ CopyDigestListToBuffer (
|
||||||
DigestSize = GetHashSizeFromAlgo (DigestList->digests[Index].hashAlg);
|
DigestSize = GetHashSizeFromAlgo (DigestList->digests[Index].hashAlg);
|
||||||
CopyMem (Buffer, &DigestList->digests[Index].digest, DigestSize);
|
CopyMem (Buffer, &DigestList->digests[Index].digest, DigestSize);
|
||||||
Buffer = (UINT8 *)Buffer + DigestSize;
|
Buffer = (UINT8 *)Buffer + DigestSize;
|
||||||
|
DigestListCount++;
|
||||||
}
|
}
|
||||||
|
WriteUnaligned32 (DigestListCountPtr, DigestListCount);
|
||||||
|
|
||||||
return Buffer;
|
return Buffer;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue