From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id EACFA81F2B for ; Thu, 17 Nov 2016 00:05:35 -0800 (PST) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP; 17 Nov 2016 00:05:40 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,504,1473145200"; d="scan'208";a="32397510" Received: from shwdeopenpsi068.ccr.corp.intel.com ([10.239.9.9]) by fmsmga006.fm.intel.com with ESMTP; 17 Nov 2016 00:05:39 -0800 From: Star Zeng To: edk2-devel@lists.01.org Cc: Star Zeng , Jiewen Yao , Chao Zhang Date: Thu, 17 Nov 2016 16:05:36 +0800 Message-Id: <1479369936-63064-1-git-send-email-star.zeng@intel.com> X-Mailer: git-send-email 2.7.0.windows.1 Subject: [PATCH V2] SecurityPkg TPM2: Assign real copied count in CopyDigestListToBuffer() X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Nov 2016 08:05:36 -0000 In CopyDigestListToBuffer() of Tpm2CommandLib, the count in returned Buffer should be real copied DigestList count. Cc: Jiewen Yao Cc: Chao Zhang Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Star Zeng --- 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