Limit the response buffer size to the negotiated size#577
Merged
Conversation
Limit the variable indicating to the caller how many bytes were returned in a TPM response to the size returned from TPM2_GetBufferSize(). This then reflects the buffer size that was negotiated with the TPMLIB_SetBufferSize() call and for which the recipient of the buffer should have enough space for. Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
The minimum buffer size was set to MAX_CONTEXT_SIZE + 128, which is fine if the assumption that the actual biggest command or response buffer is created by TPM2_ContextLoad/Save commands holds. If the assumption was not holding, then the choice of the minimum buffer size would truncate response sizes. Adjust this size to the sizeof(TPMS_CONTEXT), which is 80 bytes bigger than MAX_CONTEXT_SIZE but still related to TPM2_ContextLoad/Save commands. Still add a generous additional 128 bytes to it. Add a comment about the maximum size and the sizes used by TIS and CRB. Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
9fd2858 to
50faf22
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR deals with buffer sizes