Skip to content

Commit

Permalink
tpm: fix suspicious sizeof
Browse files Browse the repository at this point in the history
The sizeof on dest in str_padded_copy requires the src to be a fixed
buffer. Since the vendor variable is a UINT32, use sizeof(vendor) over
sizeof(&vendor), which is the size of the pointer not the target.

Signed-off-by: William Roberts <william.c.roberts@intel.com>
  • Loading branch information
William Roberts committed Sep 10, 2021
1 parent 20f8d05 commit 57ea2ad
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/lib/tpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,8 @@ CK_RV tpm_get_token_info (tpm_ctx *ctx, CK_TOKEN_INFO *info) {
vendor[1] = ntohl(tpmProperties[TPM2_PT_VENDOR_STRING_2 - TPM2_PT_FIXED].value);
vendor[2] = ntohl(tpmProperties[TPM2_PT_VENDOR_STRING_3 - TPM2_PT_FIXED].value);
vendor[3] = ntohl(tpmProperties[TPM2_PT_VENDOR_STRING_4 - TPM2_PT_FIXED].value);
str_padded_copy(info->model, (unsigned char*) &vendor);
_str_padded_copy(info->model, sizeof(info->model), (unsigned char*)
&vendor, sizeof(vendor));

return CKR_OK;
}
Expand Down

0 comments on commit 57ea2ad

Please sign in to comment.