Skip to content

Fix #3636: enforce Wildcard Subscription Available gate on client side#3659

Open
ryzhov-artem wants to merge 2 commits into
eclipse-mosquitto:developfrom
ryzhov-artem:fix/wildcard-sub
Open

Fix #3636: enforce Wildcard Subscription Available gate on client side#3659
ryzhov-artem wants to merge 2 commits into
eclipse-mosquitto:developfrom
ryzhov-artem:fix/wildcard-sub

Conversation

@ryzhov-artem

@ryzhov-artem ryzhov-artem commented Jun 1, 2026

Copy link
Copy Markdown

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:

  • Have you signed the Eclipse Contributor Agreement, using the same email address as you used in your commits?
  • Do each of your commits have a "Signed-off-by" line, with the correct email address? Use "git commit -s" to generate this line for you.
  • If you are contributing a new feature, is your work based off the develop branch?
  • If you are contributing a bugfix, is your work based off the fixes branch?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you successfully run make test with your changes locally?

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>
Copilot AI review requested due to automatic review settings June 1, 2026 17:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_available to the client state and initialize it to “available” by default.
  • Read Wildcard Subscription Available from 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 thread lib/actions_subscribe.c
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 thread test/lib/c/02-subscribe-wildcard-unavailable-v5.c
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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants