intel / ehsm

An End-to-End Distributed and Scalable Cloud KMS (Key Management System) built on top of Intel SGX enclave-based HSM (Hardware Security Module), aka eHSM.

Home Page:https://community.intel.com/t5/Blogs/Tech-Innovation/open-intel/An-Intel-SGX-based-Hardware-Security-Module-backed-Key/post/1360130?wapkw=eHSM

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug: memory leak

nntp4 opened this issue · comments

commented

memory leak happened in import_struct_from_json() function.

ehsm_keymetadata_t *out_data = (ehsm_keymetadata_t *)malloc(sizeof(ehsm_keymetadata_t));
if (out_data == NULL)
return;
out_data->keyspec = (ehsm_keyspec_t)payloadJson.readData_uint32("keyspec");
out_data->digest_mode = (ehsm_digest_mode_t)payloadJson.readData_uint32("digest_mode");
out_data->padding_mode = (ehsm_padding_mode_t)payloadJson.readData_uint32("padding_mode");
out_data->origin = (ehsm_keyorigin_t)payloadJson.readData_uint32("origin");
out_data->purpose = (ehsm_keypurpose_t)payloadJson.readData_uint32("purpose");
*out = (T *)malloc(sizeof(ehsm_keymetadata_t));
if (*out == NULL)
{
explicit_bzero(out_data, sizeof(ehsm_keymetadata_t));
return;
}

at lines 103 to 105, out_data is allocated but not free.

Thanks. Fixed.
BTW, you can submit patches directly if you are interested.