Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Leakage of mosq->tls_engine in mosquitto_destroy #2995

Open
CastleOnTheHill opened this issue Feb 6, 2024 · 0 comments
Open

Leakage of mosq->tls_engine in mosquitto_destroy #2995

CastleOnTheHill opened this issue Feb 6, 2024 · 0 comments

Comments

@CastleOnTheHill
Copy link
Contributor

Issue Description

  • Version: v2.0.18
  • Platform: Ubuntu 22

Analysis

When a user sets the tls engine using mosquitto_opts_set(mosq, MOSQ_OPT_TLS_ENGINE, engine), Mosquitto copies the engine name and stores it in mosq->tls_engine.

However, when calling mosquitto_destroy, the memory allocated for mosq->tls_engine is not freed.

Suggestions

To address this issue, please ensure that you free mosq->tls_engine in the mosquitto_destroy function.

--- a/lib/mosquitto.c
+++ b/lib/mosquitto.c
@@ -284,6 +284,11 @@ 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant