mqtt_is_valid() and the mqtt_field_value() converter accept several
messages the specifications forbid:
- a CONNECT with the Will QoS set to 3. The only check rejected the
case where both QoS bits are set without the Will flag, so neither
"Will QoS 3 with Will" nor "Will QoS 1 or Will Retain without Will"
was caught (MQTT 3.1.1 3.1.2.6/3.1.2.7, MQTT 5.0 3.1.2.6/3.1.2.7);
- an MQTT 3.1.1 CONNECT with the Password flag but not the User Name
flag (MQTT 3.1.1 3.1.2.9; MQTT 5.0 allows it, so only 3.1.1 is
checked);
- an MQTT 3.1.1 CONNACK with a return code above 5, e.g. 200 (MQTT
3.1.1 3.2.2.3 only defines 0 to 5).
For example mqtt_is_valid returns 1 for a 3.1.1 CONNECT with flags 0x1c
or 0x40, and for a 3.1.1 CONNACK "20 02 00 c8". Reject these messages.