diff --git a/platform/src/key_keeper.cpp b/platform/src/key_keeper.cpp index c466092..b63ce58 100644 --- a/platform/src/key_keeper.cpp +++ b/platform/src/key_keeper.cpp @@ -218,7 +218,6 @@ static EVP_PKEY* transform_key_to_EVP(const char* str) static struct keyring_private* get_keyring_from_response(const char* data) { - X509* cert = NULL; X509* chain_cert = NULL; struct keyring_private* _kyr=NULL; @@ -290,7 +289,6 @@ error_out: if(key) EVP_PKEY_free(key); if(chain) sk_X509_pop_free(chain, X509_free); return NULL; - } static long keyring_local_cache_query_cb(void * data, const uchar * key, uint size, void * user_arg) @@ -335,17 +333,23 @@ static void certstore_rpc_on_succ(void* result, void* user) struct tfe_rpc_response_result* response = tfe_rpc_release(result); int status_code = response->status_code; const char* status_msg = response->status_msg; - char* data = response->data; - size_t len = response->len; + if(status_code == HTTP_OK) { - *(data+len) = '\0'; - struct keyring_private* kyr= get_keyring_from_response(data); + /* Copy a buffer ending with zero */ + char * data_as_string = (char *)malloc(response->len + 1); + memcpy(data_as_string, response->data, response->len); + data_as_string[response->len] = '\0'; + + struct keyring_private* kyr= get_keyring_from_response(data_as_string); + FREE(&data_as_string); + if(kyr == NULL) { promise_failed(p, FUTURE_ERROR_EXCEPTION, "get_keyring_from_response failed"); return; } + if(!ctx->ref_keeper->no_cache) { keyring_ref_inc(kyr); diff --git a/plugin/business/decrypt-mirroring/src/decrypt_mirror_plugin.cpp b/plugin/business/decrypt-mirroring/src/decrypt_mirror_plugin.cpp index 697c091..8eb3e35 100644 --- a/plugin/business/decrypt-mirroring/src/decrypt_mirror_plugin.cpp +++ b/plugin/business/decrypt-mirroring/src/decrypt_mirror_plugin.cpp @@ -26,8 +26,7 @@ int decrypt_mirror_on_open_cb(const struct tfe_stream * stream, unsigned int thr enum tfe_stream_action decrypt_mirror_on_data_cb(const struct tfe_stream * stream, unsigned int thread_id, enum tfe_conn_dir dir, const unsigned char * data, size_t len, void ** pme) { - int ret=0; - ret=mirror_stream_write(dir, data,len, pme, thread_id); + mirror_stream_write(dir, data,len, pme, thread_id); return ACTION_FORWARD_DATA; }