Attention is currently required from: Christian Walter.
Sergii Dmytruk has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/69708 )
Change subject: security/tpm/tspi/log.c: fix strncpy() usage ......................................................................
security/tpm/tspi/log.c: fix strncpy() usage
Change-Id: Ib24129829bef3764a8ba1e2c0d92bc42c5cfbc8d Signed-off-by: Sergii Dmytruk sergii.dmytruk@3mdeb.com --- M src/security/tpm/tspi/log.c 1 file changed, 17 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/08/69708/1
diff --git a/src/security/tpm/tspi/log.c b/src/security/tpm/tspi/log.c index 96c3087..e33cacb 100644 --- a/src/security/tpm/tspi/log.c +++ b/src/security/tpm/tspi/log.c @@ -77,6 +77,8 @@
struct tpm_cb_log_entry *tce = &tclt->entries[tclt->num_entries++]; strncpy(tce->name, name, TPM_CB_LOG_PCR_HASH_NAME - 1); + tce->name[TPM_CB_LOG_PCR_HASH_NAME - 1] = '\0'; + tce->pcr = pcr;
if (digest_len > TPM_CB_LOG_DIGEST_MAX_LENGTH) { @@ -143,7 +145,10 @@
for (i = 0; i < from_log->num_entries; i++) { struct tpm_cb_log_entry *tce = &to_log->entries[to_log->num_entries++]; + strncpy(tce->name, from_log->entries[i].name, TPM_CB_LOG_PCR_HASH_NAME - 1); + tce->name[TPM_CB_LOG_PCR_HASH_NAME - 1] = '\0'; + tce->pcr = from_log->entries[i].pcr;
if (from_log->entries[i].digest_length > TPM_CB_LOG_DIGEST_MAX_LENGTH) { @@ -153,6 +158,8 @@
strncpy(tce->digest_type, from_log->entries[i].digest_type, TPM_CB_LOG_PCR_HASH_LEN - 1); + tce->digest_type[TPM_CB_LOG_PCR_HASH_LEN - 1] = '\0'; + tce->digest_length = MIN(from_log->entries[i].digest_length, TPM_CB_LOG_DIGEST_MAX_LENGTH); memcpy(tce->digest, from_log->entries[i].digest, tce->digest_length);