From 890c5982a17b591d2a42a5c75f4266bf03bf0504 Mon Sep 17 00:00:00 2001 From: Dirk Ziegelmeier Date: Sun, 8 Jan 2017 19:07:43 +0100 Subject: [PATCH] MQTT: Fix possible bug in connect message generation that WILL flag can be set without appending a will message The boolean condition of setting the WILL flag differs from that of appending the will message Found by Axel Lin (I fixed it the same way as Axel suggested, but I wanted a different commit message) (cherry picked from commit 6d5ddb713946120fa75d8e12e2f0770501e5cefa) --- src/apps/mqtt/mqtt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apps/mqtt/mqtt.c b/src/apps/mqtt/mqtt.c index a8588a1a..c46e76af 100644 --- a/src/apps/mqtt/mqtt.c +++ b/src/apps/mqtt/mqtt.c @@ -1292,7 +1292,7 @@ mqtt_client_connect(mqtt_client_t *client, const ip_addr_t *ip_addr, u16_t port, /* Append client id */ mqtt_output_append_string(&client->output, client_info->client_id, client_id_length); /* Append will message if used */ - if (will_topic_len > 0) { + if ((flags & MQTT_CONNECT_FLAG_WILL) != 0) { mqtt_output_append_string(&client->output, client_info->will_topic, will_topic_len); mqtt_output_append_string(&client->output, client_info->will_msg, will_msg_len); }