• Bug#1103927: mosquitto_2.0.11-1.2+deb12u2.debdiff (4/5)

    From Philippe Coval@21:1/5 to All on Tue Apr 22 23:50:01 2025
    [continued from previous message]

    + src/persist_read.c | 2 +-
    + src/plugin_public.c | 2 +-
    + src/subs.c | 13 +++++--------
    + test/unit/persist_read_stubs.c | 3 +--
    + test/unit/subs_test.c | 2 +-
    + 10 files changed, 15 insertions(+), 21 deletions(-)
    +
    +diff --git a/apps/db_dump/stubs.c b/apps/db_dump/stubs.c
    +index 42a1429..845053d 100644
    +--- a/apps/db_dump/stubs.c
    ++++ b/apps/db_dump/stubs.c
    +@@ -96,14 +96,13 @@ int retain__store(const char *topic, struct mosquitto_msg_store *stored, char **
    + return 0;
    + }
    +
    +-int sub__add(struct mosquitto *context, const char *sub, uint8_t qos, uint32_t identifier, int options, struct mosquitto__subhier **root)
    ++int sub__add(struct mosquitto *context, const char *sub, uint8_t qos, uint32_t identifier, int options)
    + {
    + UNUSED(context);
    + UNUSED(sub);
    + UNUSED(qos);
    + UNUSED(identifier);
    + UNUSED(options);
    +- UNUSED(root);
    + return 0;
    + }
    +
    +diff --git a/src/bridge.c b/src/bridge.c
    +index 9ca367a..0ec5284 100644
    +--- a/src/bridge.c
    ++++ b/src/bridge.c
    +@@ -380,8 +380,7 @@ int bridge__connect(struct mosquitto *context)
    + context->bridge->topics[i].local_topic,
    + qos,
    + 0,
    +- MQTT_SUB_OPT_NO_LOCAL | MQTT_SUB_OPT_RETAIN_AS_PUBLISHED,
    +- &db.subs) > 0){
    ++ MQTT_SUB_OPT_NO_LOCAL | MQTT_SUB_OPT_RETAIN_AS_PUBLISHED) > 0){
    +
    + return 1;
    + }
    +diff --git a/src/handle_subscribe.c b/src/handle_subscribe.c
    +index 2a72c59..5540dc6 100644
    +--- a/src/handle_subscribe.c
    ++++ b/src/handle_subscribe.c
    +@@ -185,7 +185,7 @@ int handle__subscribe(struct mosquitto *context)
    + }
    +
    + if(allowed){
    +- rc2 = sub__add(context, sub, qos, subscription_identifier, subscription_options, &db.subs);
    ++ rc2 = sub__add(context, sub, qos, subscription_identifier, subscription_options);
    + if(rc2 > 0){
    + mosquitto__free(sub);
    + return rc2;
    +diff --git a/src/handle_unsubscribe.c b/src/handle_unsubscribe.c
    +index 2162b46..ede49e2 100644
    +--- a/src/handle_unsubscribe.c
    ++++ b/src/handle_unsubscribe.c
    +@@ -126,7 +126,7 @@ int handle__unsubscribe(struct mosquitto *context)
    +
    + log__printf(NULL, MOSQ_LOG_DEBUG, "\t%s", sub);
    + if(allowed){
    +- rc = sub__remove(context, sub, db.subs, &reason);
    ++ rc = sub__remove(context, sub, &reason);
    + }else{
    + rc = MOSQ_ERR_SUCCESS;
    + }
    +diff --git a/src/mosquitto_broker_internal.h b/src/mosquitto_broker_internal.h +index 657c1ce..339304c 100644
    +--- a/src/mosquitto_broker_internal.h
    ++++ b/src/mosquitto_broker_internal.h
    +@@ -672,9 +672,9 @@ int db__message_write_queued_in(struct mosquitto *context);
    + /* ============================================================
    + * Subscription functions
    + * ============================================================ */
    +-int sub__add(struct mosquitto *context, const char *sub, uint8_t qos, uint32_t identifier, int options, struct mosquitto__subhier **root);
    ++int sub__add(struct mosquitto *context, const char *sub, uint8_t qos, uint32_t identifier, int options);
    + struct mosquitto__subhier *sub__add_hier_entry(struct mosquitto__subhier *parent, struct mosquitto__subhier **sibling, const char *topic, uint16_t len);
    +-int sub__remove(struct mosquitto *context, const char *sub, struct mosquitto__subhier *root, uint8_t *reason);
    ++int sub__remove(struct mosquitto *context, const char *sub, uint8_t *reason); + void sub__tree_print(struct mosquitto__subhier *root, int level);
    + int sub__clean_session(struct mosquitto *context);
    + int sub__messages_queue(const char *source_id, const char *topic, uint8_t qos, int retain, struct mosquitto_msg_store **stored);
    +diff --git a/src/persist_read.c b/src/persist_read.c
    +index 4fedfea..b58533e 100644
    +--- a/src/persist_read.c
    ++++ b/src/persist_read.c
    +@@ -556,7 +556,7 @@ static int persist__restore_sub(const char *client_id, const char *sub, uint8_t
    +
    + context = persist__find_or_add_context(client_id, 0);
    + if(!context) return 1;
    +- return sub__add(context, sub, qos, identifier, options, &db.subs);
    ++ return sub__add(context, sub, qos, identifier, options);
    + }
    +
    + #endif
    +diff --git a/src/plugin_public.c b/src/plugin_public.c
    +index 754793b..95904d9 100644
    +--- a/src/plugin_public.c
    ++++ b/src/plugin_public.c
    +@@ -283,7 +283,7 @@ static void check_subscription_acls(struct mosquitto *context)
    + MOSQ_ACL_SUBSCRIBE);
    +
    + if(rc != MOSQ_ERR_SUCCESS){
    +- sub__remove(context, context->subs[i]->topic_filter, db.subs, &reason);
    ++ sub__remove(context, context->subs[i]->topic_filter, &reason);
    + }
    + }
    + }
    +diff --git a/src/subs.c b/src/subs.c
    +index 2ccafbc..8e1a848 100644
    +--- a/src/subs.c
    ++++ b/src/subs.c
    +@@ -575,7 +575,7 @@ struct mosquitto__subhier *sub__add_hier_entry(struct mosquitto__subhier *parent
    + }
    +
    +
    +-int sub__add(struct mosquitto *context, const char *sub, uint8_t qos, uint32_t identifier, int options, struct mosquitto__subhier **root)
    ++int sub__add(struct mosquitto *context, const char *sub, uint8_t qos, uint32_t identifier, int options)
    + {
    + int rc = 0;
    + struct mosquitto__subhier *subhier;
    +@@ -584,8 +584,6 @@ int sub__add(struct mosquitto *context, const char *sub, uint8_t qos, uint32_t i
    + char **topics;
    + size_t topiclen;
    +
    +- assert(root);
    +- assert(*root);
    + assert(sub);
    +
    + rc = sub__topic_tokenise(sub, &local_sub, &topics, &sharename);
    +@@ -597,9 +595,9 @@ int sub__add(struct mosquitto *context, const char *sub, uint8_t qos, uint32_t i
    + mosquitto__free(topics);
    + return MOSQ_ERR_INVAL;
    + }
    +- HASH_FIND(hh, *root, topics[0], topiclen, subhier);
    ++ HASH_FIND(hh, db.subs, topics[0], topiclen, subhier);
    + if(!subhier){
    +- subhier = sub__add_hier_entry(NULL, root, topics[0], (uint16_t)topiclen);
    ++ subhier = sub__add_hier_entry(NULL, &db.subs, topics[0], (uint16_t)topiclen);
    + if(!subhier){
    + mosquitto__free(local_sub);
    + mosquitto__free(topics);
    +@@ -616,7 +614,7 @@ int sub__add(struct mosquitto *context, const char *sub, uint8_t qos, uint32_t i
    + return rc;
    + }
    +
    +-int sub__remove(struct mosquitto *context, const char *sub, struct mosquitto__subhier *root, uint8_t *reason)
    ++int sub__remove(struct mosquitto *context, const char *sub, uint8_t *reason) + {
    + int rc = 0;
    + struct mosquitto__subhier *subhier;
    +@@ -624,13 +622,12 @@ int sub__remove(struct mosquitto *context, const char *sub, struct mosquitto__su
    + char *local_sub = NULL;
    + char **topics = NULL;
    +
    +- assert(root);
    + assert(sub);
    +
    + rc = sub__topic_tokenise(sub, &local_sub, &topics, &sharename);
    + if(rc) return rc;
    +
    +- HASH_FIND(hh, root, topics[0], strlen(topics[0]), subhier);
    ++ HASH_FIND(hh, db.subs, topics[0], strlen(topics[0]), subhier);
    + if(subhier){
    + *reason = MQTT_RC_NO_SUBSCRIPTION_EXISTED;
    + rc = sub__remove_recurse(context, subhier, topics, reason, sharename);
    +diff --git a/test/unit/persist_read_stubs.c b/test/unit/persist_read_stubs.c +index 62b0356..c0c5d88 100644
    +--- a/test/unit/persist_read_stubs.c
    ++++ b/test/unit/persist_read_stubs.c
    +@@ -149,11 +149,10 @@ int acl__find_acls(struct mosquitto *context)
    + }
    +
    +
    +-int sub__add(struct mosquitto *context, const char *sub, uint8_t qos, uint32_t identifier, int options, struct mosquitto__subhier **root)
    ++int sub__add(struct mosquitto *context, const char *sub, uint8_t qos, uint32_t identifier, int options)
    + {
    + UNUSED(context);
    + UNUSED(options);
    +- UNUSED(root);
    +
    + last_sub = strdup(sub);
    + last_qos = qos;
    +diff --git a/test/unit/subs_test.c b/test/unit/subs_test.c
    +index a596e8b..6095d62 100644
    +--- a/test/unit/subs_test.c
    ++++ b/test/unit/subs_test.c
    +@@ -58,7 +58,7 @@ static void TEST_sub_add_single(void)
    +
    + db__open(&config);
    +
    +- rc = sub__add(&context, "a/b/c/d/e", 0, 0, 0, &db.subs);
    ++ rc = sub__add(&context, "a/b/c/d/e", 0, 0, 0);
    + CU_ASSERT_EQUAL(rc, MOSQ_ERR_SUCCESS);
    + CU_ASSERT_PTR_NOT_NULL(db.subs);
    + if(db.subs){
    diff -Nru mosquitto-2.0.11/debian/patches/CVE-2024-8376-2of3.patch mosquitto-2.0.11/debian/patches/CVE-2024-8376-2of3.patch
    --- mosquitto-2.0.11/debian/patches/CVE-2024-8376-2of3.patch 1970-01-01 01:00:00.000000000 +0100
    +++ mosquitto-2.0.11/debian/patches/CVE-2024-8376-2of3.patch 2025-04-22 21:39:19.000000000 +0200
    @@ -0,0 +1,188 @@
    +From: "Roger A. Light" <roger@atchoo.org>
    +Date: Sat, 8 Jun 2024 09:41:08 +0100
    +Subject: CVE-2024-8376-2of3
    +
    +Fixes Eclipse #217, #218.
    +
    +Origin: https://github.com/eclipse-mosquitto/mosquitto/commit/1914b3ee2a18102d0a94cbdbbfeae1afa03edd17
    +Last-Update: 2024-11-01
    +Signed-off-by: Philippe Coval <rzr@users.sf.net>
    +---
    + src/database.c | 13 +++++++++----
    + src/loop.c | 3 ++-
    + src/mosquitto_broker_internal.h | 3 ++-
    + src/persist_write.c | 8 +++++++-
    + src/subs.c | 42 +++++++++++++++++++++++++++++++----------
    + test/unit/subs_test.c | 9 +++++----
    + 6 files changed, 57 insertions(+), 21 deletions(-)
    +
    +diff --git a/src/database.c b/src/database.c
    +index b6ea83b..bf7d108 100644
    +--- a/src/data