From f09ea91e11f243abdad343da9eedb614d53ac5a1 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Tue, 12 Sep 2023 23:09:24 +0100 Subject: [PATCH 01/11] Fix crash on subscribe under certain unlikely conditions. Closes #2885. Closes #2881. Thanks to everybody on those issues. --- ChangeLog.txt | 8 ++++++++ config.mk | 9 +++++++++ src/subs.c | 2 -- test/broker/data/REGRESSION.json | 18 ++++++++++++++++++ 4 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 test/broker/data/REGRESSION.json diff --git a/ChangeLog.txt b/ChangeLog.txt index 7976dbd3..67679137 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,11 @@ +2.0.18 - 2023-09-12 +=================== + +Broker: +- Fix crash on subscribe under certain unlikely conditions. Closes #2885. + Closes #2881. + + 2.0.17 - 2023-08-22 =================== diff --git a/config.mk b/config.mk index b8bcf86d..aebb6010 100644 --- a/config.mk +++ b/config.mk @@ -120,6 +120,9 @@ WITH_JEMALLOC:=no # probably of no particular interest to end users. WITH_XTREPORT=no +# Build using clang and with address sanitiser enabled +WITH_ASAN=no + # ============================================================================= # End of user configuration # ============================================================================= @@ -152,6 +155,12 @@ else CFLAGS?=-Wall -ggdb -O2 -Wconversion -Wextra endif +ifeq ($(WITH_ASAN),yes) + CC:=clang + CFLAGS+=-fsanitize=address + LDFLAGS+=-fsanitize=address +endif + STATIC_LIB_DEPS:= APP_CPPFLAGS=$(CPPFLAGS) -I. -I../../ -I../../include -I../../src -I../../lib diff --git a/src/subs.c b/src/subs.c index c5c6b5a3..687537d9 100644 --- a/src/subs.c +++ b/src/subs.c @@ -389,7 +389,6 @@ static int sub__remove_normal(struct mosquitto *context, struct mosquitto__subhi if(context->subs[i] && context->subs[i]->hier == subhier){ mosquitto__free(context->subs[i]); context->subs[i] = NULL; - context->sub_count--; break; } } @@ -430,7 +429,6 @@ static int sub__remove_shared(struct mosquitto *context, struct mosquitto__subhi mosquitto__free(context->subs[i]); context->subs[i] = NULL; - context->sub_count--; break; } } diff --git a/test/broker/data/REGRESSION.json b/test/broker/data/REGRESSION.json new file mode 100644 index 00000000..4f21fa68 --- /dev/null +++ b/test/broker/data/REGRESSION.json @@ -0,0 +1,18 @@ +[ + { + "group": "REGRESSIONS", + "tests": [ + { "name": "subscribe-unsubscribe-crash part 1", "ver":4, "expect_disconnect":false, "msgs": [ + {"type":"send", "payload":"82 26 1234 0009 64 72 61 73 68 2F 31 2F 23 00 0009 65 72 61 73 68 2F 32 2F 23 00 0009 63 72 61 73 68 2F 33 2F 23 00"}, + {"type":"recv", "payload":"90 05 1234 00 00 00"}, + {"type":"send", "payload":"A2 0D 1234 0009 64 72 61 73 68 2F 31 2F 23"}, + {"type":"recv", "payload":"B0 02 1234"} + ], "comment": "Must be used with part 2 immediately after", + "comment2": "Requires WITH_ASAN=yes"}, + { "name": "subscribe-unsubscribe-crash part 2", "ver":4, "expect_disconnect":false, "msgs": [ + {"type":"send", "payload":"82 0E 1234 0009 63 72 61 73 68 2F 33 2F 23 00"}, + {"type":"recv", "payload":"90 03 1234 00"} + ], "comment": "https://github.com/eclipse/mosquitto/issues/2885"} + ] + } +] From 66c62767354f986cad928779027eb7d5182c77c8 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Tue, 12 Sep 2023 23:11:54 +0100 Subject: [PATCH 02/11] Fix protocol --- docker/1.5-openssl/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/1.5-openssl/Dockerfile b/docker/1.5-openssl/Dockerfile index 69ade540..afbaa745 100644 --- a/docker/1.5-openssl/Dockerfile +++ b/docker/1.5-openssl/Dockerfile @@ -45,7 +45,7 @@ RUN set -x && \ export GNUPGHOME="$(mktemp -d)" && \ found=''; \ for server in \ - htps://keys.openpgp.org \ + hkps://keys.openpgp.org \ hkp://keyserver.ubuntu.com:80 \ pgp.mit.edu \ ; do \ From 7ae22c356be5c567503357917fca818c4d076c5a Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Wed, 13 Sep 2023 09:02:55 +0100 Subject: [PATCH 03/11] Fix mosquitto_rr not honouring `-R`. Closes #2893. Thanks to jwinder-ca --- ChangeLog.txt | 3 +++ client/rr_client.c | 31 ++++--------------------------- 2 files changed, 7 insertions(+), 27 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 67679137..f75338e2 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -5,6 +5,9 @@ Broker: - Fix crash on subscribe under certain unlikely conditions. Closes #2885. Closes #2881. +Clients: +- Fix mosquitto_rr not honouring `-R`. Closes #2893. + 2.0.17 - 2023-08-22 =================== diff --git a/client/rr_client.c b/client/rr_client.c index e74536f7..eb98b7f8 100644 --- a/client/rr_client.c +++ b/client/rr_client.c @@ -84,7 +84,11 @@ static void my_message_callback(struct mosquitto *mosq, void *obj, const struct UNUSED(obj); UNUSED(properties); + if(process_messages == false) return; + if(message->retain && cfg.no_retain) return; + print_message(&cfg, message, properties); + switch(cfg.pub_mode){ case MSGMODE_CMD: case MSGMODE_FILE: @@ -96,33 +100,6 @@ static void my_message_callback(struct mosquitto *mosq, void *obj, const struct client_state = rr_s_ready_to_publish; break; } - /* FIXME - check all below - if(process_messages == false) return; - - if(cfg.retained_only && !message->retain && process_messages){ - process_messages = false; - mosquitto_disconnect_v5(mosq, 0, cfg.disconnect_props); - return; - } - - if(message->retain && cfg.no_retain) return; - if(cfg.filter_outs){ - for(i=0; itopic, &res); - if(res) return; - } - } - - //print_message(&cfg, message); - - if(cfg.msg_count>0){ - msg_count++; - if(cfg.msg_count == msg_count){ - process_messages = false; - mosquitto_disconnect_v5(mosq, 0, cfg.disconnect_props); - } - } - */ } void my_connect_callback(struct mosquitto *mosq, void *obj, int result, int flags, const mosquitto_property *properties) From 97c25654ed4778c76a89682b0b20e4ccf95b5a88 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Mon, 18 Sep 2023 22:21:56 +0100 Subject: [PATCH 04/11] Add helper messages for lax permissions --- lib/misc_mosq.c | 10 ++++++---- plugins/dynamic-security/plugin.c | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/misc_mosq.c b/lib/misc_mosq.c index 3ee6fc79..844c9b6d 100644 --- a/lib/misc_mosq.c +++ b/lib/misc_mosq.c @@ -158,8 +158,9 @@ FILE *mosquitto__fopen(const char *path, const char *mode, bool restrict_read) #else fprintf(stderr, #endif - "Warning: File %s has world readable permissions. Future versions will refuse to load this file.", - path); + "Warning: File %s has world readable permissions. Future versions will refuse to load this file.\n" + "To fix this, use `chmod 0700 %s`.", + path, path); #if 0 return NULL; #endif @@ -175,8 +176,9 @@ FILE *mosquitto__fopen(const char *path, const char *mode, bool restrict_read) #else fprintf(stderr, #endif - "Warning: File %s owner is not %s. Future versions will refuse to load this file.", - path, result->pw_name); + "Warning: File %s owner is not %s. Future versions will refuse to load this file." + "To fix this, use `chown %s %s`.", + path, result->pw_name, result->pw_name, path); } #if 0 // Future version diff --git a/plugins/dynamic-security/plugin.c b/plugins/dynamic-security/plugin.c index b5b81fc1..125052e6 100644 --- a/plugins/dynamic-security/plugin.c +++ b/plugins/dynamic-security/plugin.c @@ -166,8 +166,9 @@ FILE *mosquitto__fopen(const char *path, const char *mode, bool restrict_read) #else fprintf(stderr, #endif - "Warning: File %s has world readable permissions. Future versions will refuse to load this file.", - path); + "Warning: File %s has world readable permissions. Future versions will refuse to load this file." + "To fix this, use `chmod 0700 %s`.", + path, path); #if 0 return NULL; #endif @@ -183,8 +184,9 @@ FILE *mosquitto__fopen(const char *path, const char *mode, bool restrict_read) #else fprintf(stderr, #endif - "Warning: File %s owner is not %s. Future versions will refuse to load this file.", - path, result->pw_name); + "Warning: File %s owner is not %s. Future versions will refuse to load this file." + "To fix this, use `chown %s %s`.", + path, result->pw_name, result->pw_name, path); } #if 0 // Future version From 3923526c6b4c048bbecad2506c4c9963bc46cd36 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Mon, 18 Sep 2023 22:22:14 +0100 Subject: [PATCH 05/11] Bump version, add webpage. --- CMakeLists.txt | 2 +- ChangeLog.txt | 2 +- config.mk | 2 +- include/mosquitto.h | 2 +- installer/mosquitto.nsi | 2 +- installer/mosquitto64.nsi | 2 +- set-version.sh | 2 +- snap/snapcraft.yaml | 2 +- www/posts/2023/08/version-2-0-17-released.md | 6 ++--- www/posts/2023/09/version-2-0-18-released.md | 23 ++++++++++++++++++++ 10 files changed, 34 insertions(+), 11 deletions(-) create mode 100644 www/posts/2023/09/version-2-0-18-released.md diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d337c9d..088e9a92 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ cmake_minimum_required(VERSION 3.1) cmake_policy(SET CMP0042 NEW) project(mosquitto) -set (VERSION 2.0.17) +set (VERSION 2.0.18) list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/") diff --git a/ChangeLog.txt b/ChangeLog.txt index f75338e2..0d7b3df0 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,4 +1,4 @@ -2.0.18 - 2023-09-12 +2.0.18 - 2023-09-18 =================== Broker: diff --git a/config.mk b/config.mk index aebb6010..6e0139c1 100644 --- a/config.mk +++ b/config.mk @@ -130,7 +130,7 @@ WITH_ASAN=no # Also bump lib/mosquitto.h, CMakeLists.txt, # installer/mosquitto.nsi, installer/mosquitto64.nsi -VERSION=2.0.17 +VERSION=2.0.18 # Client library SO version. Bump if incompatible API/ABI changes are made. SOVERSION=1 diff --git a/include/mosquitto.h b/include/mosquitto.h index 2f3c6384..5633b407 100644 --- a/include/mosquitto.h +++ b/include/mosquitto.h @@ -66,7 +66,7 @@ extern "C" { #define LIBMOSQUITTO_MAJOR 2 #define LIBMOSQUITTO_MINOR 0 -#define LIBMOSQUITTO_REVISION 17 +#define LIBMOSQUITTO_REVISION 18 /* LIBMOSQUITTO_VERSION_NUMBER looks like 1002001 for e.g. version 1.2.1. */ #define LIBMOSQUITTO_VERSION_NUMBER (LIBMOSQUITTO_MAJOR*1000000+LIBMOSQUITTO_MINOR*1000+LIBMOSQUITTO_REVISION) diff --git a/installer/mosquitto.nsi b/installer/mosquitto.nsi index 284f1641..85030cbc 100644 --- a/installer/mosquitto.nsi +++ b/installer/mosquitto.nsi @@ -9,7 +9,7 @@ !define env_hklm 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"' Name "Eclipse Mosquitto" -!define VERSION 2.0.17 +!define VERSION 2.0.18 OutFile "mosquitto-${VERSION}-install-windows-x86.exe" InstallDir "$PROGRAMFILES\mosquitto" diff --git a/installer/mosquitto64.nsi b/installer/mosquitto64.nsi index fc502241..7c9a544b 100644 --- a/installer/mosquitto64.nsi +++ b/installer/mosquitto64.nsi @@ -9,7 +9,7 @@ !define env_hklm 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"' Name "Eclipse Mosquitto" -!define VERSION 2.0.17 +!define VERSION 2.0.18 OutFile "mosquitto-${VERSION}-install-windows-x64.exe" !include "x64.nsh" diff --git a/set-version.sh b/set-version.sh index ee8d287b..b0a179d3 100755 --- a/set-version.sh +++ b/set-version.sh @@ -2,7 +2,7 @@ MAJOR=2 MINOR=0 -REVISION=17 +REVISION=18 sed -i "s/^VERSION=.*/VERSION=${MAJOR}.${MINOR}.${REVISION}/" config.mk diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 16af47ff..53919a34 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,5 +1,5 @@ name: mosquitto -version: 2.0.17 +version: 2.0.18 summary: Eclipse Mosquitto MQTT broker description: This is a message broker that supports version 5.0, 3.1.1, and 3.1 of the MQTT protocol. diff --git a/www/posts/2023/08/version-2-0-17-released.md b/www/posts/2023/08/version-2-0-17-released.md index 4dd16a48..aae33410 100644 --- a/www/posts/2023/08/version-2-0-17-released.md +++ b/www/posts/2023/08/version-2-0-17-released.md @@ -1,6 +1,6 @@ -Version 2.0.16 of Mosquitto has been released. This is a bugfix release. +Version 2.0.17 of Mosquitto has been released. This is a bugfix release. Broker: - Fix `max_queued_messages 0` stopping clients from receiving messages. diff --git a/www/posts/2023/09/version-2-0-18-released.md b/www/posts/2023/09/version-2-0-18-released.md new file mode 100644 index 00000000..4c234e3c --- /dev/null +++ b/www/posts/2023/09/version-2-0-18-released.md @@ -0,0 +1,23 @@ + + +Version 2.0.18 of Mosquitto has been released. This is a bugfix release. + +Broker: +- Fix crash on subscribe under certain unlikely conditions. Closes [#2885]. + Closes [#2881]. + +Clients: +- Fix mosquitto_rr not honouring `-R`. Closes [#2893]. + +[#2881]: https://github.com/eclipse/mosquitto/issues/2881 +[#2885]: https://github.com/eclipse/mosquitto/issues/2885 +[#2893]: https://github.com/eclipse/mosquitto/issues/2893 From f4400fa422eacac8417efbc45dd1284526dce8d4 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Mon, 18 Sep 2023 22:32:22 +0100 Subject: [PATCH 06/11] Bump docker --- docker/2.0-openssl/Dockerfile | 4 ++-- docker/2.0/Dockerfile | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docker/2.0-openssl/Dockerfile b/docker/2.0-openssl/Dockerfile index 5219bf6f..9f6cd190 100644 --- a/docker/2.0-openssl/Dockerfile +++ b/docker/2.0-openssl/Dockerfile @@ -3,8 +3,8 @@ FROM alpine:3.18 LABEL maintainer="Roger Light " \ description="Eclipse Mosquitto MQTT Broker" -ENV VERSION=2.0.17 \ - DOWNLOAD_SHA256=3be7a911236567c1a9fbe25baf3e3167004ba4a0c151a448ef1f7fc077dba52f \ +ENV VERSION=2.0.18 \ + DOWNLOAD_SHA256=d665fe7d0032881b1371a47f34169ee4edab67903b2cd2b4c083822823f4448a \ GPG_KEYS=A0D6EEA1DCAE49A635A3B2F0779B22DFB3E717B7 \ LWS_VERSION=4.2.1 \ LWS_SHA256=842da21f73ccba2be59e680de10a8cce7928313048750eb6ad73b6fa50763c51 diff --git a/docker/2.0/Dockerfile b/docker/2.0/Dockerfile index 8241190d..78212d2d 100644 --- a/docker/2.0/Dockerfile +++ b/docker/2.0/Dockerfile @@ -3,8 +3,8 @@ FROM alpine:3.18 LABEL maintainer="Roger Light " \ description="Eclipse Mosquitto MQTT Broker" -ENV VERSION=2.0.17 \ - DOWNLOAD_SHA256=3be7a911236567c1a9fbe25baf3e3167004ba4a0c151a448ef1f7fc077dba52f \ +ENV VERSION=2.0.18 \ + DOWNLOAD_SHA256=d665fe7d0032881b1371a47f34169ee4edab67903b2cd2b4c083822823f4448a \ GPG_KEYS=A0D6EEA1DCAE49A635A3B2F0779B22DFB3E717B7 \ LWS_VERSION=4.2.1 \ LWS_SHA256=842da21f73ccba2be59e680de10a8cce7928313048750eb6ad73b6fa50763c51 From 5b011ff112f991caec0b9292988f06e872341b44 Mon Sep 17 00:00:00 2001 From: Gianfranco Costamagna Date: Wed, 22 Jan 2020 12:39:49 +0100 Subject: [PATCH 07/11] Add dynamic symbols linking with cmake too Signed-off-by: Gianfranco Costamagna --- lib/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 31cc35e3..f0f71132 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -94,6 +94,8 @@ set_target_properties(libmosquitto PROPERTIES OUTPUT_NAME mosquitto VERSION ${VERSION} SOVERSION 1 + LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/linker.version + LINK_FLAGS "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/linker.version" ) install(TARGETS libmosquitto From 87565238fd1fe063cddb2f5e99c2e9ef3cad1c00 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Fri, 29 Sep 2023 00:43:16 +0100 Subject: [PATCH 08/11] Document keepalive=0 is allowed --- include/mosquitto.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/mosquitto.h b/include/mosquitto.h index 2f3c6384..72ef9f77 100644 --- a/include/mosquitto.h +++ b/include/mosquitto.h @@ -507,7 +507,7 @@ libmosq_EXPORT int mosquitto_username_pw_set(struct mosquitto *mosq, const char * * mosq == NULL * * host == NULL * * port < 0 - * * keepalive < 5 + * * keepalive < 5 (keepalive == 0 is allowed, for an infinite keepalive) * MOSQ_ERR_ERRNO - if a system call returned an error. The variable errno * contains the error code, even on Windows. * Use strerror_r() where available or FormatMessage() on @@ -587,7 +587,7 @@ libmosq_EXPORT int mosquitto_connect_bind(struct mosquitto *mosq, const char *ho * * mosq == NULL * * host == NULL * * port < 0 - * * keepalive < 5 + * * keepalive < 5 (keepalive == 0 is allowed, for an infinite keepalive) * MOSQ_ERR_ERRNO - if a system call returned an error. The variable errno * contains the error code, even on Windows. * Use strerror_r() where available or FormatMessage() on From 15292b20b0894ec7c5c3d47e4b22ee9d89f91132 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Fri, 6 Oct 2023 16:20:43 +0100 Subject: [PATCH 09/11] Update security page --- www/pages/security.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/www/pages/security.md b/www/pages/security.md index 94768ea5..d682a17d 100644 --- a/www/pages/security.md +++ b/www/pages/security.md @@ -19,7 +19,13 @@ follow the steps on [Eclipse Security] page to report it. Listed with most recent first. Further information on security related issues can be found in the [security category]. -* June 2023: [CVE-2023-28366]: Clients sending unacknowledged QoS 2 messages +* August 2023: [CVE-2023-0809]: Fix excessive memory being allocated based on + malicious initial packets that are not CONNECT packets. Affecting versions + **1.5.0** to **2.0.15**. Fixed in **2.0.16**. +* August 2023: [CVE-2023-3592]: Fix memory leak when clients send v5 CONNECT + packets with a will message that contains invalid property types. Affecting + version **1.6.0** to **2.0.15** Fixed in **2.0.16**. +* August 2023: [CVE-2023-28366]: Clients sending unacknowledged QoS 2 messages with duplicate message ids cause a memory leak. Affecting versions **1.3.2** to **2.0.15** inclusive, fixed in **2.0.16**. * August 2022: Deleting the anonymous group in the dynamic security plugin From 28590fa38397e8b6b8f24e6ab361784ad63217af Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Wed, 15 Nov 2023 22:45:38 +0000 Subject: [PATCH 10/11] Remove unused headers --- client/rr_client.c | 1 - client/sub_client.c | 1 - client/sub_client_output.c | 1 - lib/property_mosq.c | 1 - lib/util_topic.c | 1 - src/context.c | 1 - src/handle_publish.c | 1 - src/loop.c | 1 - src/mosquitto.c | 1 - src/mux_epoll.c | 1 - src/net.c | 1 - src/persist_read_v234.c | 1 - src/persist_read_v5.c | 1 - src/persist_write_v5.c | 1 - src/property_broker.c | 1 - src/read_handle.c | 1 - src/topic_tok.c | 1 - 17 files changed, 17 deletions(-) diff --git a/client/rr_client.c b/client/rr_client.c index eb98b7f8..c91e247d 100644 --- a/client/rr_client.c +++ b/client/rr_client.c @@ -18,7 +18,6 @@ Contributors: #include "config.h" -#include #include #include #include diff --git a/client/sub_client.c b/client/sub_client.c index 4ff3bf9a..6e2a1fb4 100644 --- a/client/sub_client.c +++ b/client/sub_client.c @@ -18,7 +18,6 @@ Contributors: #include "config.h" -#include #include #include #include diff --git a/client/sub_client_output.c b/client/sub_client_output.c index 8bf7cdb5..a0722d7c 100644 --- a/client/sub_client_output.c +++ b/client/sub_client_output.c @@ -25,7 +25,6 @@ Contributors: # include #endif -#include #include #include #include diff --git a/lib/property_mosq.c b/lib/property_mosq.c index 0b27c297..758fe574 100644 --- a/lib/property_mosq.c +++ b/lib/property_mosq.c @@ -18,7 +18,6 @@ Contributors: #include "config.h" -#include #include #include diff --git a/lib/util_topic.c b/lib/util_topic.c index e29102f7..658b2f9e 100644 --- a/lib/util_topic.c +++ b/lib/util_topic.c @@ -18,7 +18,6 @@ Contributors: #include "config.h" -#include #include #ifdef WIN32 diff --git a/src/context.c b/src/context.c index 837be458..d838fc76 100644 --- a/src/context.c +++ b/src/context.c @@ -18,7 +18,6 @@ Contributors: #include "config.h" -#include #include #include "mosquitto_broker_internal.h" diff --git a/src/handle_publish.c b/src/handle_publish.c index d3aa5ce2..eb0cef3e 100644 --- a/src/handle_publish.c +++ b/src/handle_publish.c @@ -18,7 +18,6 @@ Contributors: #include "config.h" -#include #include #include diff --git a/src/loop.c b/src/loop.c index dbc16ae3..a5a63e77 100644 --- a/src/loop.c +++ b/src/loop.c @@ -23,7 +23,6 @@ Contributors: # define _GNU_SOURCE #endif -#include #ifndef WIN32 #include #else diff --git a/src/mosquitto.c b/src/mosquitto.c index 431254d8..6304c08c 100644 --- a/src/mosquitto.c +++ b/src/mosquitto.c @@ -22,7 +22,6 @@ Contributors: /* For initgroups() */ # include # include -# include #endif #ifndef WIN32 diff --git a/src/mux_epoll.c b/src/mux_epoll.c index 414aa604..4532cf55 100644 --- a/src/mux_epoll.c +++ b/src/mux_epoll.c @@ -25,7 +25,6 @@ Contributors: # define _GNU_SOURCE #endif -#include #ifndef WIN32 #ifdef WITH_EPOLL #include diff --git a/src/net.c b/src/net.c index 8fab9b3d..b66c03d9 100644 --- a/src/net.c +++ b/src/net.c @@ -31,7 +31,6 @@ Contributors: # include #endif -#include #include #include #include diff --git a/src/persist_read_v234.c b/src/persist_read_v234.c index 49147bba..f240bec5 100644 --- a/src/persist_read_v234.c +++ b/src/persist_read_v234.c @@ -23,7 +23,6 @@ Contributors: #ifndef WIN32 #include #endif -#include #include #include #include diff --git a/src/persist_read_v5.c b/src/persist_read_v5.c index 173046ed..0caab5fb 100644 --- a/src/persist_read_v5.c +++ b/src/persist_read_v5.c @@ -23,7 +23,6 @@ Contributors: #ifndef WIN32 #include #endif -#include #include #include #include diff --git a/src/persist_write_v5.c b/src/persist_write_v5.c index 8c9f6c34..8d82646c 100644 --- a/src/persist_write_v5.c +++ b/src/persist_write_v5.c @@ -23,7 +23,6 @@ Contributors: #ifndef WIN32 #include #endif -#include #include #include #include diff --git a/src/property_broker.c b/src/property_broker.c index a0c856a9..f2fb5427 100644 --- a/src/property_broker.c +++ b/src/property_broker.c @@ -18,7 +18,6 @@ Contributors: #include "config.h" -#include #include #include diff --git a/src/read_handle.c b/src/read_handle.c index b1cba917..f34e8685 100644 --- a/src/read_handle.c +++ b/src/read_handle.c @@ -18,7 +18,6 @@ Contributors: #include "config.h" -#include #include #include diff --git a/src/topic_tok.c b/src/topic_tok.c index 340e0b6f..5d0efd9e 100644 --- a/src/topic_tok.c +++ b/src/topic_tok.c @@ -18,7 +18,6 @@ Contributors: #include "config.h" -#include #include #include From fd097d5a0f4d26f5d5ae35cf1fb326c373ad39e1 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Wed, 15 Nov 2023 23:08:04 +0000 Subject: [PATCH 11/11] Fix assert failure when loading a persistence file. If the file contains subscriptions with no client id. --- ChangeLog.txt | 8 ++++++++ src/persist_read.c | 10 ++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 0d7b3df0..a3ab2ebe 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,11 @@ +2.0.19 - 2023-11-xx +=================== + +Broker: +- Fix assert failure when loading a persistence file that contains + subscriptions with no client id. + + 2.0.18 - 2023-09-18 =================== diff --git a/src/persist_read.c b/src/persist_read.c index 14a2f4f0..47deb5b6 100644 --- a/src/persist_read.c +++ b/src/persist_read.c @@ -547,8 +547,14 @@ static int persist__restore_sub(const char *client_id, const char *sub, uint8_t { struct mosquitto *context; - assert(client_id); - assert(sub); + if(!client_id){ + log__printf(NULL, MOSQ_LOG_WARNING, "Warning: Persistence found a subscription with no client id, ignoring."); + return MOSQ_ERR_SUCCESS; + } + if(!sub){ + log__printf(NULL, MOSQ_LOG_WARNING, "Warning: Persistence found a subscription with no topic filter, ignoring."); + return MOSQ_ERR_SUCCESS; + } context = persist__find_or_add_context(client_id, 0); if(!context) return 1;