Skip to content

Commit

Permalink
Shared subs must have a valid topic
Browse files Browse the repository at this point in the history
  • Loading branch information
ralight committed Oct 16, 2024
1 parent 71ddbab commit 732b8eb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/topic_tok.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ int sub__topic_tokenise(const char *subtopic, char **local_sub, char ***topics,
}

if(!strcmp((*topics)[0], "$share")){
if(count < 2){
if(count < 3 || (count == 3 && strlen((*topics)[2]) == 0)){
mosquitto__free(*local_sub);
mosquitto__free(*topics);
return MOSQ_ERR_PROTOCOL;
Expand Down
8 changes: 8 additions & 0 deletions test/broker/data/SUBSCRIBE.json
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,14 @@
{"type":"send", "payload":"82 0B 1234 00 0001 70 00 0001 71 00"},
{"type":"recv", "payload":"90 05 1234 00 00 00"}
]},
{ "name": "82 shared sub with no topic part 1", "ver":5, "msgs": [
{"type":"send", "payload":"82 0F 1234 00 0009 2473686172652F702F 00"},
{"type":"recv", "payload":"E0 01 82"}
]},
{ "name": "82 shared sub with no topic part 2", "ver":5, "msgs": [
{"type":"send", "payload":"82 0E 1234 00 0008 2473686172652F70 00"},
{"type":"recv", "payload":"E0 01 82"}
]},
{ "name": "82 shared sub with no local set", "ver":5, "msgs": [
{"type":"send", "payload":"82 10 1234 00 000A 2473686172652F702F70 04"},
{"type":"recv", "payload":"E0 01 82"}
Expand Down

0 comments on commit 732b8eb

Please sign in to comment.