Fix #3636: enforce Wildcard Subscription Available gate on client side#3659
Open
ryzhov-artem wants to merge 2 commits into
Open
Fix #3636: enforce Wildcard Subscription Available gate on client side#3659ryzhov-artem wants to merge 2 commits into
ryzhov-artem wants to merge 2 commits into
Conversation
Fixes eclipse-mosquitto#3636. When the server sends Wildcard Subscription Available = 0 in the CONNACK properties, the client library must not send SUBSCRIBE with '+' or '#' topic filters. Previously the property was stored but never enforced, so wildcard subscribes were sent regardless. - Add wildcard_sub_available field to struct mosquitto - Default to 1 (supported) — MQTT 5 spec: absent means supported - Reset to 1 on every (re)connect to avoid stale state from prior broker - Read MQTT_PROP_WILDCARD_SUB_AVAILABLE from CONNACK properties - Return MOSQ_ERR_WILDCARD_SUBS_NOT_SUPPORTED from subscribe API when a wildcard filter is used and the server declared unavailable Signed-off-by: Artem Ryzhov <topmarnet@gmail.com>
Signed-off-by: Artem Ryzhov <topmarnet@gmail.com>
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds client-side enforcement of the MQTT v5 Wildcard Subscription Available CONNACK property so wildcard topic filters are rejected when the server indicates they’re unsupported, and adds a C integration test covering the behavior.
Changes:
- Add
wildcard_sub_availableto the client state and initialize it to “available” by default. - Read
Wildcard Subscription Availablefrom CONNACK properties (MQTT v5). - Reject wildcard subscriptions in
mosquitto_subscribe_multiple()when the server reports they’re unavailable; add a C test to verify.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| test/lib/c/02-subscribe-wildcard-unavailable-v5.c | New integration test asserting wildcard subscriptions are rejected client-side when unavailable. |
| lib/mosquitto_internal.h | Adds internal state flag for wildcard subscription availability. |
| lib/libmosquitto.c | Initializes the new wildcard-availability flag on reinitialization. |
| lib/handle_connack.c | Reads the MQTT v5 property into the new state flag. |
| lib/connect.c | Initializes the new wildcard-availability flag during connect init. |
| lib/actions_subscribe.c | Enforces the flag by rejecting wildcard topic filters when unavailable. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+93
to
+97
| if(!mosq->wildcard_sub_available){ | ||
| if(strchr(sub[i], '+') || strchr(sub[i], '#')){ | ||
| return MOSQ_ERR_WILDCARD_SUBS_NOT_SUPPORTED; | ||
| } | ||
| } |
Comment on lines
+85
to
+87
| while(run == -1){ | ||
| mosquitto_loop(mosq, 50, 1); | ||
| } |
Comment on lines
+71
to
+74
| mosq = mosquitto_new("subscribe-wildcard-unavailable-test", true, NULL); | ||
| if(mosq == NULL){ | ||
| return 1; | ||
| } |
Comment on lines
+80
to
+83
| rc = mosquitto_connect(mosq, "localhost", port, 60); | ||
| if(rc != MOSQ_ERR_SUCCESS){ | ||
| return rc; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thank you for contributing your time to the Mosquitto project!
Before you go any further, please note that we cannot accept contributions if
you haven't signed the Eclipse Contributor Agreement.
If you aren't able to do that, or just don't want to, please describe your bug
fix/feature change in an issue. For simple bug fixes it is can be just as easy
for us to be told about the problem and then go fix it directly.
Then please check the following list of things we ask for in your pull request:
make testwith your changes locally?