tpm2: Check returned buffer pointer after call to _rpc__Send_Command()

_rcp__SendCommand() may come back with a different buffer than what was
passed in. This happens when the TPM 2 is in failure more and the TPM 2
code uses an internal buffer. In this case we just copy from that inter-
nal buffer into the buffer that was passed into the function.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
Stefan Berger 2018-12-09 14:01:22 -05:00 committed by Stefan Berger
parent ad041fd1d4
commit b1832e9fed

View File

@ -191,6 +191,13 @@ TPM_RESULT TPM2_Process(unsigned char **respbuffer, uint32_t *resp_size,
_rpc__Send_Command(locality, req, &resp);
/* it may come back with a different buffer, especially in failure mode */
if (resp.Buffer != *respbuffer) {
if (resp.BufferSize > *respbufsize)
resp.BufferSize = *respbufsize;
memcpy(*respbuffer, resp.Buffer, resp.BufferSize);
}
*resp_size = resp.BufferSize;
return TPM_SUCCESS;