BUG/MINOR: mqtt: Support empty client ID in CONNECT message
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 28 Jun 2021 13:37:59 +0000 (15:37 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 28 Jun 2021 14:29:44 +0000 (16:29 +0200)
commit0de0becf0b024b6beca9c5f7e1ed8a08120d781c
tree034de7a55c2b22fd0f8ce2ddfd428137e4a7892f
parentca925c9c28934739311210a1cc5e19fab972c5fa
BUG/MINOR: mqtt: Support empty client ID in CONNECT message

As specified by the MQTT specification (MQTT-3.1.3-6), the client ID may be
empty. That means the length of the client ID string may be 0. However, The
MQTT parser does not support empty strings.

So, to fix the bug, the mqtt_read_string() function may now parse empty
string. 2 bytes must be found to decode the string length, but the length
may be 0 now. It is the caller responsibility to test the string emptiness
if necessary. In addition, in mqtt_parse_connect(), the client ID may be
empty now.

This patch should partely fix the issue #1310. It must be backported to 2.4.
reg-tests/converter/mqtt.vtc
src/mqtt.c