From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 34F2981EEA for ; Wed, 16 Nov 2016 05:57:55 -0800 (PST) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga104.fm.intel.com with ESMTP; 16 Nov 2016 05:58:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,500,1473145200"; d="scan'208";a="32057765" Received: from shwdeopenpsi068.ccr.corp.intel.com ([10.239.9.9]) by fmsmga006.fm.intel.com with ESMTP; 16 Nov 2016 05:57:58 -0800 From: Star Zeng To: edk2-devel@lists.01.org Cc: Star Zeng , Jiewen Yao , Chao Zhang Date: Wed, 16 Nov 2016 21:57:46 +0800 Message-Id: <1479304666-51108-1-git-send-email-star.zeng@intel.com> X-Mailer: git-send-email 2.7.0.windows.1 Subject: [PATCH] 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: Wed, 16 Nov 2016 13:57:55 -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 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c index 43574a246829..caa370c94381 100644 --- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c +++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c @@ -230,8 +230,10 @@ CopyDigestListToBuffer ( { UINTN Index; UINT16 DigestSize; + UINT32 *DigestListCount; - CopyMem (Buffer, &DigestList->count, sizeof(DigestList->count)); + DigestListCount = (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,6 +245,7 @@ CopyDigestListToBuffer ( DigestSize = GetHashSizeFromAlgo (DigestList->digests[Index].hashAlg); CopyMem (Buffer, &DigestList->digests[Index].digest, DigestSize); Buffer = (UINT8 *)Buffer + DigestSize; + (*DigestListCount)++; } return Buffer; -- 2.7.0.windows.1