mirror of
https://github.com/kakwa/uts-server
synced 2025-01-10 05:34:29 +01:00
fix some memory leaks on openssl context cleanup
This commit is contained in:
parent
d247816f5b
commit
503a09aa58
@ -20,6 +20,7 @@ typedef struct {
|
|||||||
int loglevel;
|
int loglevel;
|
||||||
const char *http_options[40];
|
const char *http_options[40];
|
||||||
TS_RESP_CTX *ts_ctx;
|
TS_RESP_CTX *ts_ctx;
|
||||||
|
CONF *conf;
|
||||||
} rfc3161_context;
|
} rfc3161_context;
|
||||||
|
|
||||||
struct rfc3161_option {
|
struct rfc3161_option {
|
||||||
|
@ -8,5 +8,6 @@ void log_hex(rfc3161_context *ct, int priority, char *id,
|
|||||||
unsigned char *content, int content_length);
|
unsigned char *content, int content_length);
|
||||||
int set_params(rfc3161_context *ct, char *conf_file, char *conf_wd);
|
int set_params(rfc3161_context *ct, char *conf_file, char *conf_wd);
|
||||||
static char *rand_string(char *str, size_t size);
|
static char *rand_string(char *str, size_t size);
|
||||||
|
void free_uts_context(rfc3161_context *context);
|
||||||
int g_uts_sig_up;
|
int g_uts_sig_up;
|
||||||
int g_uts_sig;
|
int g_uts_sig;
|
||||||
|
@ -205,7 +205,7 @@ int http_server_start(char *conffile, char *conf_wd, bool stdout_dbg) {
|
|||||||
|
|
||||||
// Stop the server.
|
// Stop the server.
|
||||||
mg_stop(ctx);
|
mg_stop(ctx);
|
||||||
free(ct);
|
free_uts_context(ct);
|
||||||
free_ssl();
|
free_ssl();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -74,6 +74,12 @@ void init_ssl(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void free_ssl() {
|
void free_ssl() {
|
||||||
|
CONF_modules_unload(1);
|
||||||
|
EVP_cleanup();
|
||||||
|
// ENGINE_cleanup();
|
||||||
|
ERR_remove_state(1);
|
||||||
|
CRYPTO_cleanup_all_ex_data();
|
||||||
|
EVP_cleanup();
|
||||||
ERR_free_strings();
|
ERR_free_strings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,8 +265,9 @@ int set_params(rfc3161_context *ct, char *conf_file, char *conf_wd) {
|
|||||||
int ret = 1;
|
int ret = 1;
|
||||||
int http_counter = 0;
|
int http_counter = 0;
|
||||||
|
|
||||||
CONF *conf = load_config_file(ct, conf_file);
|
NCONF_free(ct->conf);
|
||||||
if (conf == NULL)
|
ct->conf = load_config_file(ct, conf_file);
|
||||||
|
if (ct->conf == NULL)
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
// first pass to set the loglevel as soon as possible
|
// first pass to set the loglevel as soon as possible
|
||||||
@ -274,7 +275,7 @@ int set_params(rfc3161_context *ct, char *conf_file, char *conf_wd) {
|
|||||||
int type = rfc3161_options[i].type;
|
int type = rfc3161_options[i].type;
|
||||||
const char *name = rfc3161_options[i].name;
|
const char *name = rfc3161_options[i].name;
|
||||||
const char *default_value = rfc3161_options[i].default_value;
|
const char *default_value = rfc3161_options[i].default_value;
|
||||||
const char *value = NCONF_get_string(conf, MAIN_CONF_SECTION, name);
|
const char *value = NCONF_get_string(ct->conf, MAIN_CONF_SECTION, name);
|
||||||
if (value == NULL) {
|
if (value == NULL) {
|
||||||
uts_logger(ct, LOG_NOTICE,
|
uts_logger(ct, LOG_NOTICE,
|
||||||
"configuration param['%s'] not set, using default: '%s'",
|
"configuration param['%s'] not set, using default: '%s'",
|
||||||
@ -299,7 +300,7 @@ int set_params(rfc3161_context *ct, char *conf_file, char *conf_wd) {
|
|||||||
int type = rfc3161_options[i].type;
|
int type = rfc3161_options[i].type;
|
||||||
const char *name = rfc3161_options[i].name;
|
const char *name = rfc3161_options[i].name;
|
||||||
const char *default_value = rfc3161_options[i].default_value;
|
const char *default_value = rfc3161_options[i].default_value;
|
||||||
const char *value = NCONF_get_string(conf, MAIN_CONF_SECTION, name);
|
const char *value = NCONF_get_string(ct->conf, MAIN_CONF_SECTION, name);
|
||||||
if (value == NULL) {
|
if (value == NULL) {
|
||||||
uts_logger(ct, LOG_NOTICE,
|
uts_logger(ct, LOG_NOTICE,
|
||||||
"configuration param['%s'] not set, using default: '%s'",
|
"configuration param['%s'] not set, using default: '%s'",
|
||||||
@ -325,9 +326,9 @@ int set_params(rfc3161_context *ct, char *conf_file, char *conf_wd) {
|
|||||||
ct->http_options[http_counter] = NULL;
|
ct->http_options[http_counter] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!add_oid_section(ct, conf))
|
if (!add_oid_section(ct, ct->conf))
|
||||||
ret = 0;
|
ret = 0;
|
||||||
ct->ts_ctx = create_tsctx(ct, conf, NULL, NULL);
|
ct->ts_ctx = create_tsctx(ct, ct->conf, NULL, NULL);
|
||||||
if (ct->ts_ctx == NULL)
|
if (ct->ts_ctx == NULL)
|
||||||
ret = 0;
|
ret = 0;
|
||||||
chdir("/");
|
chdir("/");
|
||||||
@ -337,3 +338,9 @@ end:
|
|||||||
chdir("/");
|
chdir("/");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void free_uts_context(rfc3161_context *context) {
|
||||||
|
TS_RESP_CTX_free(context->ts_ctx);
|
||||||
|
NCONF_free(context->conf);
|
||||||
|
free(context);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user