From a3509ca6aa4a5bf4ad0d9babdd4f889e0d5e74b7 Mon Sep 17 00:00:00 2001 From: lxsang Date: Tue, 9 Oct 2018 12:15:48 +0200 Subject: [PATCH] open ssl still leak memory --- http_server.c | 5 +++-- httpd.c | 8 ++++++++ libs/handle.c | 7 +++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/http_server.c b/http_server.c index b6db21e..57517c4 100644 --- a/http_server.c +++ b/http_server.c @@ -203,6 +203,7 @@ void *accept_request(void *data) return task; default: LOG("Error performing SSL handshake %d %d %lu\n", stat, ret, ERR_get_error()); + server_config.connection++; ERR_print_errors_fp(stderr); return task; } @@ -339,7 +340,7 @@ void *resolve_request(void *data) if (h) { //sprintf(path,"/%s%s",h,url); - LOG("WARNING::::Access octetstream via handler %s\n", h); + LOG("WARNING::::Access octetstream via handle %s\n", h); //if(execute_plugin(client,buf,method,rq) < 0) // cannot_execute(client); free(task); @@ -941,7 +942,7 @@ void *decode_multi_part_request_data(void *data) } else { - LOG("Cannot wirte file to :%s\n", file_path); + LOG("Cannot write file to :%s\n", file_path); } free(file_path); free(part_file); diff --git a/httpd.c b/httpd.c index 15d33d2..7e53812 100644 --- a/httpd.c +++ b/httpd.c @@ -85,7 +85,15 @@ void stop_serve(int dummy) { unload_all_plugin(); destroy_config(); #ifdef USE_OPENSSL + FIPS_mode_set(0); SSL_CTX_free(ctx); + FIPS_mode_set(0); + CONF_modules_unload(1); + EVP_cleanup(); + ENGINE_cleanup(); + CRYPTO_cleanup_all_ex_data(); + ERR_remove_state(0); + ERR_free_strings(); #endif close(server_sock); sigprocmask(SIG_UNBLOCK, &mask, NULL); diff --git a/libs/handle.c b/libs/handle.c index 2c2bdc2..ae01c8f 100644 --- a/libs/handle.c +++ b/libs/handle.c @@ -234,6 +234,13 @@ int antd_close(void* src) SSL_set_shutdown((SSL*) source->ssl, SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN); //printf("SSL:Free ssl\n"); SSL_free((SSL*) source->ssl); + + //EVP_cleanup(); + //ENGINE_cleanup(); + CRYPTO_cleanup_all_ex_data(); + ERR_remove_state(0); + ERR_free_strings(); + source->ssl = NULL; //LOG("Freeing SSL\n"); } #endif