public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH V2] SecurityPkg TPM2: Assign real copied count in CopyDigestListToBuffer()
@ 2016-11-17  8:05 Star Zeng
  2016-11-17 12:09 ` Yao, Jiewen
  0 siblings, 1 reply; 2+ messages in thread
From: Star Zeng @ 2016-11-17  8:05 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng, Jiewen Yao, Chao Zhang

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>
---
 SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
index 43574a246829..be95fd69b3dd 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;
 }
-- 
2.7.0.windows.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH V2] SecurityPkg TPM2: Assign real copied count in CopyDigestListToBuffer()
  2016-11-17  8:05 [PATCH V2] SecurityPkg TPM2: Assign real copied count in CopyDigestListToBuffer() Star Zeng
@ 2016-11-17 12:09 ` Yao, Jiewen
  0 siblings, 0 replies; 2+ messages in thread
From: Yao, Jiewen @ 2016-11-17 12:09 UTC (permalink / raw)
  To: Zeng, Star, edk2-devel@lists.01.org; +Cc: Zhang, Chao B

Reviewed-by: jiewen.yao@intel.com

> -----Original Message-----
> From: Zeng, Star
> Sent: Thursday, November 17, 2016 4:06 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star <star.zeng@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>;
> Zhang, Chao B <chao.b.zhang@intel.com>
> Subject: [PATCH V2] 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>
> ---
>  SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
> b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
> index 43574a246829..be95fd69b3dd 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].hashA
> lg, 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;
>  }
> --
> 2.7.0.windows.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-11-17 12:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-17  8:05 [PATCH V2] SecurityPkg TPM2: Assign real copied count in CopyDigestListToBuffer() Star Zeng
2016-11-17 12:09 ` Yao, Jiewen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox