mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-12-25 00:14:02 +00:00
mqtt: allow user + pass longer than 255 chars
See bug #54655: "MQTT brokers such as Google Cloud IoT Core requires MQTT clients to send JSON Web Token (JWT) as password field of the MQTT Connect packet. JWT can be more than 255 bytes. Currently, the MQTT library restricts password to be less than 256 bytes, thus it prevents connectivity to Google Cloud IoT Core." Fix that by just converting the local variables for these from u8_t to u16_t. Suggested-by: Richmond Umagat <richmond.umagat@brtchip.com> Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
This commit is contained in:
parent
796f98beb2
commit
0189e7b02f
@ -1289,7 +1289,7 @@ mqtt_client_connect(mqtt_client_t *client, const ip_addr_t *ip_addr, u16_t port,
|
||||
/* Length is the sum of 2+"MQTT", protocol level, flags and keep alive */
|
||||
u16_t remaining_length = 2 + 4 + 1 + 1 + 2;
|
||||
u8_t flags = 0, will_topic_len = 0, will_msg_len = 0;
|
||||
u8_t client_user_len = 0, client_pass_len = 0;
|
||||
u16_t client_user_len = 0, client_pass_len = 0;
|
||||
|
||||
LWIP_ASSERT_CORE_LOCKED();
|
||||
LWIP_ASSERT("mqtt_client_connect: client != NULL", client != NULL);
|
||||
@ -1330,9 +1330,9 @@ mqtt_client_connect(mqtt_client_t *client, const ip_addr_t *ip_addr, u16_t port,
|
||||
if (client_info->client_user != NULL) {
|
||||
flags |= MQTT_CONNECT_FLAG_USERNAME;
|
||||
len = strlen(client_info->client_user);
|
||||
LWIP_ERROR("mqtt_client_connect: client_info->client_user length overflow", len <= 0xFF, return ERR_VAL);
|
||||
LWIP_ERROR("mqtt_client_connect: client_info->client_user length overflow", len <= 0xFFFF, return ERR_VAL);
|
||||
LWIP_ERROR("mqtt_client_connect: client_info->client_user length must be > 0", len > 0, return ERR_VAL);
|
||||
client_user_len = (u8_t)len;
|
||||
client_user_len = (u16_t)len;
|
||||
len = remaining_length + 2 + client_user_len;
|
||||
LWIP_ERROR("mqtt_client_connect: remaining_length overflow", len <= 0xFFFF, return ERR_VAL);
|
||||
remaining_length = (u16_t)len;
|
||||
@ -1340,9 +1340,9 @@ mqtt_client_connect(mqtt_client_t *client, const ip_addr_t *ip_addr, u16_t port,
|
||||
if (client_info->client_pass != NULL) {
|
||||
flags |= MQTT_CONNECT_FLAG_PASSWORD;
|
||||
len = strlen(client_info->client_pass);
|
||||
LWIP_ERROR("mqtt_client_connect: client_info->client_pass length overflow", len <= 0xFF, return ERR_VAL);
|
||||
LWIP_ERROR("mqtt_client_connect: client_info->client_pass length overflow", len <= 0xFFFF, return ERR_VAL);
|
||||
LWIP_ERROR("mqtt_client_connect: client_info->client_pass length must be > 0", len > 0, return ERR_VAL);
|
||||
client_pass_len = (u8_t)len;
|
||||
client_pass_len = (u16_t)len;
|
||||
len = remaining_length + 2 + client_pass_len;
|
||||
LWIP_ERROR("mqtt_client_connect: remaining_length overflow", len <= 0xFFFF, return ERR_VAL);
|
||||
remaining_length = (u16_t)len;
|
||||
|
Loading…
Reference in New Issue
Block a user