From fd097d5a0f4d26f5d5ae35cf1fb326c373ad39e1 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Wed, 15 Nov 2023 23:08:04 +0000 Subject: [PATCH] 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;