Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix leakage of mosq->tls_engine and User SSL Context #3023

Open
wants to merge 1 commit into
base: fixes
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions lib/mosquitto.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ int mosquitto_reinitialise(struct mosquitto *mosq, const char *id, bool clean_st
mosq->ssl = NULL;
mosq->ssl_ctx = NULL;
mosq->ssl_ctx_defaults = true;
#ifndef WITH_BROKER
mosq->user_ssl_ctx = NULL;
#endif
mosq->tls_cert_reqs = SSL_VERIFY_PEER;
mosq->tls_insecure = false;
mosq->want_write = false;
Expand Down Expand Up @@ -267,9 +270,17 @@ void mosquitto__destroy(struct mosquitto *mosq)
if(mosq->ssl){
SSL_free(mosq->ssl);
}
if(mosq->ssl_ctx){
SSL_CTX_free(mosq->ssl_ctx);
}
#ifndef WITH_BROKER
if(mosq->user_ssl_ctx){
SSL_CTX_free(mosq->user_ssl_ctx);
}else if(mosq->ssl_ctx){
SSL_CTX_free(mosq->ssl_ctx);
}
#else
if(mosq->ssl_ctx){
SSL_CTX_free(mosq->ssl_ctx);
}
#endif
mosquitto__free(mosq->tls_cafile);
mosquitto__free(mosq->tls_capath);
mosquitto__free(mosq->tls_certfile);
Expand All @@ -280,6 +291,10 @@ void mosquitto__destroy(struct mosquitto *mosq)
mosquitto__free(mosq->tls_psk);
mosquitto__free(mosq->tls_psk_identity);
mosquitto__free(mosq->tls_alpn);
#ifndef OPENSSL_NO_ENGINE
mosquitto__free(mosq->tls_engine);
mosq->tls_engine = NULL;
#endif
#endif

mosquitto__free(mosq->address);
Expand Down