Skip to content

Commit

Permalink
Send protocol error on topic alias not found.
Browse files Browse the repository at this point in the history
The error topic-alias-invalid was being sent if an MQTT v5 client published
a message with empty topic and topic alias set, but the topic alias hadn't
already been configured on the broker. This has been fixed to send a
protocol error, as per section 3.3.4 of the specification.
  • Loading branch information
ralight committed Jan 20, 2021
1 parent 3c58ac9 commit cf1098e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ Broker:
- Fix reloading of listeners where multiple listeners have been defined with
the same port but different bind addresses. Closes #2029.
- Fix `message_size_limit` not applying to the Will payload. Closes #2022.
- The error topic-alias-invalid was being sent if an MQTT v5 client published
a message with empty topic and topic alias set, but the topic alias hadn't
already been configured on the broker. This has been fixed to send a
protocol error, as per section 3.3.4 of the specification.

Apps:
- Allow command line arguments to override config file options in
Expand Down
2 changes: 1 addition & 1 deletion src/handle_publish.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ int handle__publish(struct mosquitto *context)
rc = alias__find(context, &msg->topic, (uint16_t)topic_alias);
if(rc){
db__msg_store_free(msg);
return MOSQ_ERR_TOPIC_ALIAS_INVALID;
return MOSQ_ERR_PROTOCOL;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/broker/02-subpub-qos0-topic-alias-unknown.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def do_test():
props = mqtt5_props.gen_uint16_prop(mqtt5_props.PROP_TOPIC_ALIAS, 3)
publish1_packet = mosq_test.gen_publish("", qos=0, payload="message", proto_ver=5, properties=props)

disconnect_packet = mosq_test.gen_disconnect(reason_code=148, proto_ver=5)
disconnect_packet = mosq_test.gen_disconnect(reason_code=mqtt5_rc.MQTT_RC_PROTOCOL_ERROR, proto_ver=5)

port = mosq_test.get_port()
broker = mosq_test.start_broker(filename=os.path.basename(__file__), port=port)
Expand Down

0 comments on commit cf1098e

Please sign in to comment.