From db8f762c41042ffb7ca471143b169cc686de8889 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Wed, 24 Jul 2019 11:13:07 +0100 Subject: [PATCH] Fix MQTT v5 sub opts being set for v3 subs. Closes #1353. Thanks to Ben Barbour. --- ChangeLog.txt | 4 ++++ lib/actions.c | 3 +++ lib/mosquitto.h | 5 +++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 53a3dc1339..33a6cf3d98 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -7,6 +7,10 @@ Broker: - Windows: Allow other applications access to the log file when running. Closes #515. +Client library: +- Fix MQTT v5 subscription options being incorrectly set for MQTT v3 + subscriptions. Closes #1353. + 1.6.3 - 20190618 ================ diff --git a/lib/actions.c b/lib/actions.c index a5bf673fa9..b17c560f84 100644 --- a/lib/actions.c +++ b/lib/actions.c @@ -200,6 +200,9 @@ int mosquitto_subscribe_multiple(struct mosquitto *mosq, int *mid, int sub_count return MOSQ_ERR_OVERSIZE_PACKET; } } + if(mosq->protocol == mosq_p_mqtt311 || mosq->protocol == mosq_p_mqtt31){ + options = 0; + } return send__subscribe(mosq, mid, sub_count, sub, qos|options, outgoing_properties); } diff --git a/lib/mosquitto.h b/lib/mosquitto.h index 09bba66e08..d939bfd2da 100644 --- a/lib/mosquitto.h +++ b/lib/mosquitto.h @@ -921,8 +921,9 @@ libmosq_EXPORT int mosquitto_subscribe_v5(struct mosquitto *mosq, int *mid, cons * familiar with this, just think of it as a safer "char **", * equivalent to "const char *" for a simple string pointer. * qos - the requested Quality of Service for each subscription. - * options - options to apply to this subscription, OR'd together. Set to 0 to - * use the default options, otherwise choose from the list: + * options - options to apply to this subscription, OR'd together. This + * argument is not used for MQTT v3 susbcriptions. Set to 0 to use + * the default options, otherwise choose from the list: * MQTT_SUB_OPT_NO_LOCAL - with this option set, if this client * publishes to a topic to which it is subscribed, the * broker will not publish the message back to the