diff --git a/common/src/tfe_http.cpp b/common/src/tfe_http.cpp index 234c96b..5ddf56f 100644 --- a/common/src/tfe_http.cpp +++ b/common/src/tfe_http.cpp @@ -109,16 +109,16 @@ struct http_field_name * http_field_construct_from_string(const char * str_field return NULL; } -const char * http_field_to_string(const struct http_field_name * field) +const char * http_field_name_to_string(const struct http_field_name * field) { if (field->field_id != TFE_HTTP_UNKNOWN_FIELD) return __str_std_header_field_map[field->field_id]; return field->field_name; } -void http_field_destory(struct http_field_name * field) +void http_field_name_destory(struct http_field_name * field) { - if(field->field_id == TFE_HTTP_UNKNOWN_FIELD) FREE(&field->field_name); - free(field); + if(field->field_id == TFE_HTTP_UNKNOWN_FIELD) free((void*)field->field_name); + FREE(&(field)); } struct http_frame_session_ctx diff --git a/common/src/tfe_rpc.cpp b/common/src/tfe_rpc.cpp index 8496435..bd2b673 100644 --- a/common/src/tfe_rpc.cpp +++ b/common/src/tfe_rpc.cpp @@ -159,7 +159,7 @@ void connection_close_cb(struct evhttp_connection* connection, void* arg) //printf("call connection_close_cb\n"); } -char* get_request_url(struct evhttp_uri* uri, int url_len) +char* get_request_url(struct evhttp_uri* uri, size_t url_len) { const char* path = evhttp_uri_get_path(uri); const char* query = evhttp_uri_get_query(uri); @@ -184,6 +184,11 @@ char* get_request_url(struct evhttp_uri* uri, int url_len) //data is for POST. if method is GET, data should be NULL void tfe_rpc_async_ask(struct future* f, const char* url, enum TFE_RPC_METHOD method, enum TFE_RPC_FLAG flag, const char* data, int data_len, struct event_base * evbase, struct evdns_base* dnsbase) { + const char* host=NULL; + int port=0; + size_t url_len=0; + char* request_url=NULL; + struct evhttp_request* request=NULL; struct promise* p = future_to_promise(f); struct tfe_rpc_ctx* ctx = ALLOC(struct tfe_rpc_ctx, 1); ctx->evbase = evbase; @@ -196,13 +201,13 @@ void tfe_rpc_async_ask(struct future* f, const char* url, enum TFE_RPC_METHOD me _wrapped_promise_failed(p, FUTURE_ERROR_EXCEPTION, "parse url failed!"); goto error_out; } - const char* host = evhttp_uri_get_host(uri); + host = evhttp_uri_get_host(uri); if(!host) { _wrapped_promise_failed(p, FUTURE_ERROR_EXCEPTION, "parse host failed!"); goto error_out; } - int port = evhttp_uri_get_port(uri); + port = evhttp_uri_get_port(uri); if(port < 0) { port = 80; @@ -215,7 +220,7 @@ void tfe_rpc_async_ask(struct future* f, const char* url, enum TFE_RPC_METHOD me goto error_out; } evhttp_connection_set_closecb(ctx->connection, connection_close_cb, evbase); - struct evhttp_request* request = evhttp_request_new(get_response_cb, (void*)p); + request = evhttp_request_new(get_response_cb, (void*)p); //evhttp_request_set_header_cb(request, read_header_done_cb); if(flag == CHUNK_CB) { @@ -223,8 +228,8 @@ void tfe_rpc_async_ask(struct future* f, const char* url, enum TFE_RPC_METHOD me } evhttp_request_set_error_cb(request, request_error_cb); evhttp_add_header(evhttp_request_get_output_headers(request), "Host", host); - int url_len = strlen(url); - char* request_url = get_request_url(uri, url_len); + url_len = strlen(url); + request_url = get_request_url(uri, url_len); //printf("request url is %s\n", request_url); if(request_url == NULL) { diff --git a/platform/src/key_keeper.cpp b/platform/src/key_keeper.cpp index eaf98b0..ec72591 100644 --- a/platform/src/key_keeper.cpp +++ b/platform/src/key_keeper.cpp @@ -275,41 +275,31 @@ static EVP_PKEY* transform_key_to_EVP(const char* str) return key; } - -static void err_out(X509* cert, EVP_PKEY* key, STACK_OF(X509)* chain) -{ - if(cert) - { - X509_free(cert); - } - if(key) - { - EVP_PKEY_free(key); - } - if(chain) - { - sk_X509_pop_free(chain, X509_free); - } - return; -} - static struct keyring_private* get_keyring_from_response(const char* data) { + X509* cert = NULL; + X509* chain_cert = NULL; + struct keyring_private* _kyr=NULL; + EVP_PKEY* key = NULL; STACK_OF(X509)* chain = NULL; + cJSON* data_json = NULL; + cJSON* chain_cert_json = NULL; + cJSON* cert_json = NULL; + cJSON* key_json = NULL; + cJSON* chain_json = NULL; + if(data == NULL) { goto error_out; } - cJSON* data_json = cJSON_Parse(data); + data_json = cJSON_Parse(data); if(data_json == NULL) { goto error_out; } - cJSON* cert_json = NULL; - cJSON* key_json = NULL; - cJSON* chain_json = NULL; + cert_json = cJSON_GetObjectItemCaseSensitive(data_json, "CERTIFICATE"); key_json = cJSON_GetObjectItemCaseSensitive(data_json, "PRIVATE_KEY"); chain_json = cJSON_GetObjectItemCaseSensitive(data_json, "CERTIFICATE_CHAIN"); @@ -333,11 +323,10 @@ static struct keyring_private* get_keyring_from_response(const char* data) { goto error_out; } - cJSON* chain_cert_json = NULL; chain = sk_X509_new_null(); cJSON_ArrayForEach(chain_cert_json, chain_json) { - X509* chain_cert = NULL; + chain_cert = NULL; if (chain_cert_json && chain_cert_json->valuestring != NULL) { chain_cert = transform_cert_to_x509(chain_cert_json->valuestring); @@ -349,7 +338,7 @@ static struct keyring_private* get_keyring_from_response(const char* data) sk_X509_push(chain, chain_cert); ssl_x509_refcount_inc(chain_cert); } - struct keyring_private* _kyr= keyring_new(); + _kyr= keyring_new(); keyring_set_cert(_kyr, cert); keyring_set_key(_kyr, key); keyring_set_chain(_kyr, chain); diff --git a/plugin/business/decrypt-mirroring/src/decrypt_mirror_plugin.cpp b/plugin/business/decrypt-mirroring/src/decrypt_mirror_plugin.cpp index 7cb2200..481c9c1 100644 --- a/plugin/business/decrypt-mirroring/src/decrypt_mirror_plugin.cpp +++ b/plugin/business/decrypt-mirroring/src/decrypt_mirror_plugin.cpp @@ -1,12 +1,14 @@ #include "mirror_stream.h" #include +#include #include #include int decrypt_mirror_init(struct tfe_proxy * proxy) { const char* filepath="./conf/tfe/decrypt_mirror.conf"; - int thread_num=2, ret=0;//todo: aquire from proxy; + int thread_num=2; + UNUSED int ret=0;//todo: aquire from proxy; ret=mirror_stream_init(thread_num, filepath); // assert(ret==0); return 0; @@ -15,7 +17,7 @@ int decrypt_mirror_init(struct tfe_proxy * proxy) int decrypt_mirror_on_open_cb(const struct tfe_stream * stream, unsigned int thread_id, enum tfe_conn_dir dir, void ** pme) { - int ret=0; + UNUSED int ret=0; ret=mirror_stream_open(thread_id, stream->addr, pme); // assert(ret==0); return 0; @@ -24,7 +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; + UNUSED int ret=0; ret=mirror_stream_write(dir, data,len, pme, thread_id); return ACTION_FORWARD_DATA; }