diff --git a/ChangeLog.txt b/ChangeLog.txt index 6e2484c3..b6f9aa9b 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -50,6 +50,7 @@ Client library: - Disable TLS v1.3 when using TLS-PSK, because it isn't correctly configured. - Threaded mode is deconfigured when the mosquitto_loop_start() thread ends, which allows mosquitto_loop_start() to be called again. Closes #2242. +- Fix MOSQ_OPT_SSL_CTX not being able to be set to NULL. Closes #2289. Apps: - Fix `mosquitto_ctrl dynsec setDefaultACLAccess` command not working. diff --git a/lib/options.c b/lib/options.c index 710c0cd4..c78aa479 100644 --- a/lib/options.c +++ b/lib/options.c @@ -401,26 +401,17 @@ int mosquitto_opts_set(struct mosquitto *mosq, enum mosq_opt_t option, void *val { int ival; - if(!mosq || !value) return MOSQ_ERR_INVAL; + if(!mosq) return MOSQ_ERR_INVAL; switch(option){ case MOSQ_OPT_PROTOCOL_VERSION: + if(value == NULL){ + return MOSQ_ERR_INVAL; + } ival = *((int *)value); return mosquitto_int_option(mosq, option, ival); case MOSQ_OPT_SSL_CTX: -#ifdef WITH_TLS - mosq->ssl_ctx = (SSL_CTX *)value; - if(mosq->ssl_ctx){ -#if (OPENSSL_VERSION_NUMBER >= 0x10100000L) - SSL_CTX_up_ref(mosq->ssl_ctx); -#else - CRYPTO_add(&(mosq->ssl_ctx)->references, 1, CRYPTO_LOCK_SSL_CTX); -#endif - } - break; -#else - return MOSQ_ERR_NOT_SUPPORTED; -#endif + return mosquitto_void_option(mosq, option, value); default: return MOSQ_ERR_INVAL; } @@ -512,7 +503,7 @@ int mosquitto_int_option(struct mosquitto *mosq, enum mosq_opt_t option, int val int mosquitto_void_option(struct mosquitto *mosq, enum mosq_opt_t option, void *value) { - if(!mosq || !value) return MOSQ_ERR_INVAL; + if(!mosq) return MOSQ_ERR_INVAL; switch(option){ case MOSQ_OPT_SSL_CTX: