Send protocol error on topic alias not found.

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.
This commit is contained in:
Roger A. Light 2021-01-20 10:28:40 +00:00
parent 3c58ac9308
commit cf1098eff1
3 changed files with 6 additions and 2 deletions

View File

@ -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

View File

@ -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;
}
}
}

View File

@ -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)