Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions test/unit/test_tpm2_auth_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ static int setup(void **state) {
ESYS_CONTEXT *ectx;
size_t size = sizeof(TSS2_TCTI_CONTEXT_FAKE);
TSS2_TCTI_CONTEXT *tcti = malloc(size);
assert_non_null(tcti);

rc = tcti_fake_initialize(tcti, &size);
if (rc) {
Expand Down
1 change: 1 addition & 0 deletions test/unit/test_tpm2_session.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ TSS2_RC __wrap_Esys_TR_GetName(ESYS_CONTEXT *esysContext, ESYS_TR handle,
UNUSED(handle);

*name = malloc(sizeof(TPM2B_NAME));
assert_non_null(*name);
size_t offset = 0;
TSS2_RC rc = Tss2_MU_TPM2_HANDLE_Marshal(SESSION_HANDLE, &(*name)->name[0],
sizeof(TPM2_HANDLE), &offset);
Expand Down
9 changes: 9 additions & 0 deletions tools/tpm2_duplicate.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ static tool_rc openssl_create_duplicate(void) {
encrypted_duplicate_sensitive.size);

ctx.out_private_data = malloc(private.size + sizeof(private.size));
if (!ctx.out_private_data) {
LOG_ERR("oom");
rc = tool_rc_general_error;
goto out;
}
memcpy(ctx.out_private_data, &private, private.size + sizeof(private.size));

out:
Expand Down Expand Up @@ -231,6 +236,10 @@ static tool_rc process_openssl_duplicate(void) {

ctx.out_sym_seed = malloc(encrypted_seed.size +
sizeof(encrypted_seed.size));
if (!ctx.out_sym_seed) {
LOG_ERR("oom");
return tool_rc_general_error;
}
memcpy(ctx.out_sym_seed, &encrypted_seed,
encrypted_seed.size + sizeof(encrypted_seed.size));

Expand Down
4 changes: 4 additions & 0 deletions tools/tpm2_encryptdecrypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,10 @@ static tool_rc process_inputs(ESYS_CONTEXT *ectx, tpm2_option_flags flags) {
ctx.iv_in = 0;
} else {
ctx.iv_in = malloc(iv_start.size + sizeof(iv_start));
if (!ctx.iv_in) {
LOG_ERR("oom");
return tool_rc_general_error;
}
ctx.iv_in->size = iv_start.size;
memcpy(ctx.iv_in->buffer, &iv_start.buffer, iv_start.size);
}
Expand Down
8 changes: 8 additions & 0 deletions tools/tpm2_getekcertificate.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,10 @@ static char *encode_ek_public_amd(void) {
return NULL;
}
char *hash_str = malloc(AMD_EK_URI_LEN * 2 + NULL_TERM_LEN);
if (!hash_str) {
LOG_ERR("oom");
return NULL;
}
for (size_t i = 0; i < AMD_EK_URI_LEN; i++)
{
sprintf((char*)(hash_str + (i*2)), "%02x", hash[i]);
Expand Down Expand Up @@ -1137,6 +1141,10 @@ static tool_rc process_input(ESYS_CONTEXT *ectx) {

if (ctx.ek_path) {
ctx.out_public = malloc(sizeof(*ctx.out_public));
if (!ctx.out_public) {
LOG_ERR("oom");
return tool_rc_general_error;
}
ctx.out_public->size = 0;
bool res = files_load_public(ctx.ek_path, ctx.out_public);
if (!res) {
Expand Down
4 changes: 4 additions & 0 deletions tools/tpm2_nvreadpublic.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,10 @@ static tool_rc process_inputs(ESYS_CONTEXT *ectx) {
*/
if (!ctx.is_command_dispatch) {
ctx.nv_public_list[0] = malloc(sizeof(TPM2B_NV_PUBLIC));
if (!ctx.nv_public_list[0]) {
LOG_ERR("oom");
return tool_rc_general_error;
}
}

/*
Expand Down
4 changes: 4 additions & 0 deletions tools/tpm2_verifysignature.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ static bool on_option(char key, char *value) {
break;
case 'd': {
ctx.msg_hash = malloc(sizeof(TPM2B_DIGEST));
if (!ctx.msg_hash) {
LOG_ERR("oom");
return false;
}
ctx.msg_hash->size = sizeof(ctx.msg_hash->buffer);
if (!files_load_bytes_from_path(value, ctx.msg_hash->buffer,
&ctx.msg_hash->size)) {
Expand Down