mirror of
https://github.com/stefanberger/libtpms
synced 2026-08-12 21:35:50 +00:00
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:
parent
ad041fd1d4
commit
b1832e9fed
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user