vtpmmgr: Remove bogus cast from TPM2_GetRandom

The UINT32 <-> UINT16 casting in TPM2_GetRandom is incorrect.  Use a
local UINT16 as needed for the TPM hardware command and assign the
result.

Suggested-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Reviewed-by: Daniel P. Smith <dpsmith@apertussolutions.com>
This commit is contained in:
Jason Andryuk authored and Andrew Cooper committed 2021-05-10 14:50:33 +01:00
1 parent 64d00dd126
commit 7f4276fad8
1 file changed
+10 -3
+10 -3
View File
@@ -427,15 +427,22 @@ abort_egress:
TPM_RC TPM2_GetRandom(UINT32 * bytesRequested, BYTE * randomBytes)
{
UINT16 bytesReq;
TPM_BEGIN(TPM_ST_NO_SESSIONS, TPM_CC_GetRandom);
ptr = pack_UINT16(ptr, (UINT16)*bytesRequested);
if (*bytesRequested > UINT16_MAX)
bytesReq = UINT16_MAX;
else
bytesReq = *bytesRequested;
ptr = pack_UINT16(ptr, bytesReq);
TPM_TRANSMIT();
TPM_UNPACK_VERIFY();
ptr = unpack_UINT16(ptr, (UINT16 *)bytesRequested);
ptr = unpack_TPM_BUFFER(ptr, randomBytes, *bytesRequested);
ptr = unpack_UINT16(ptr, &bytesReq);
*bytesRequested = bytesReq;
ptr = unpack_TPM_BUFFER(ptr, randomBytes, bytesReq);
abort_egress:
return status;
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.