Skip to content

Commit

Permalink
Fix MOSQ_OPT_SSL_CTX not being able to be set to NULL.
Browse files Browse the repository at this point in the history
Closes #2289. Thanks to Poltorak Serguei.
  • Loading branch information
ralight committed Aug 31, 2021
1 parent 77af2ec commit 6051315
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
1 change: 1 addition & 0 deletions ChangeLog.txt
Expand Up @@ -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.
Expand Down
21 changes: 6 additions & 15 deletions lib/options.c
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 6051315

Please sign in to comment.