diff --git a/ChangeLog.txt b/ChangeLog.txt index e725203d..1178e908 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -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 diff --git a/src/handle_publish.c b/src/handle_publish.c index 3f9a1627..1e3d9b4f 100644 --- a/src/handle_publish.c +++ b/src/handle_publish.c @@ -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; } } } diff --git a/test/broker/02-subpub-qos0-topic-alias-unknown.py b/test/broker/02-subpub-qos0-topic-alias-unknown.py index cdce33ce..62227127 100755 --- a/test/broker/02-subpub-qos0-topic-alias-unknown.py +++ b/test/broker/02-subpub-qos0-topic-alias-unknown.py @@ -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)