From 3d3b7fc46f904aeec7cea47ec74ead235ea09408 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Wed, 15 Aug 2018 14:34:56 +0100 Subject: [PATCH] Fix default port problem when compiling clients using WITH_TLS=no. --- ChangeLog.txt | 4 ++++ client/client_shared.c | 14 +++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 52357fa5..a1dae2f0 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -32,6 +32,10 @@ Library: - Fix connection problems when mosquitto_loop_start() was called before mosquitto_connect_async(). Closes #848. +Clients: +- When compiled using WITH_TLS=no, the default port was incorrectly being set + to -1. This has been fixed. + Build: - Fixes for building on NetBSD. Closes #258. diff --git a/client/client_shared.c b/client/client_shared.c index f14ebb1e..72a585ab 100644 --- a/client/client_shared.c +++ b/client/client_shared.c @@ -978,20 +978,20 @@ int client_connect(struct mosquitto *mosq, struct mosq_config *cfg) int rc; int port; -#ifdef WITH_TLS if(cfg->port < 0){ +#ifdef WITH_TLS if(cfg->cafile || cfg->capath -#ifdef WITH_TLS_PSK +# ifdef WITH_TLS_PSK || cfg->psk -#endif +# endif ){ port = 8883; - }else{ + }else +#endif + { port = 1883; } - }else -#endif - { + }else{ port = cfg->port; }