Skip to content

Commit

Permalink
FAPI: Add size check for reading ima header.
Browse files Browse the repository at this point in the history
It's now checked whether the complete ima header is read.

Signed-off-by: Juergen Repp <[email protected]>
  • Loading branch information
JuergenReppSIT committed Feb 22, 2024
1 parent 5c62a99 commit 8dbd7fb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/tss2-fapi/ifapi_ima_eventlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -656,11 +656,17 @@ size_t read_ima_header(IFAPI_IMA_TEMPLATE *template, FILE *fp, TSS2_RC *rc)

*rc = TSS2_RC_SUCCESS;

size = fread(&template->header, header_size, 1, fp);
size = fread(&template->header, 1, header_size, fp);
if (size == 0) {
return size;
}

if (size != header_size) {
*rc = TSS2_FAPI_RC_BAD_VALUE;
LOG_ERROR("Invalid ima data");
return 0;
}

template->convert_to_big_endian = need_to_convert_to_big_endian(template);

if (memcmp(&template->header.digest[pos_ima_type], "ima", 3) == 0) {
Expand Down

0 comments on commit 8dbd7fb

Please sign in to comment.