mirror of
https://github.com/cesanta/mongoose.git
synced 2024-12-27 15:01:03 +08:00
Allow zero-length 'last-will' messages
This commit is contained in:
parent
3c3c775213
commit
2ac3552e6e
@ -4333,7 +4333,7 @@ void mg_mqtt_login(struct mg_connection *c, const struct mg_mqtt_opts *opts) {
|
||||
total_len += 2 + (uint32_t) opts->pass.len;
|
||||
hdr[7] |= MQTT_HAS_PASSWORD;
|
||||
}
|
||||
if (opts->topic.len > 0 && opts->message.len > 0) {
|
||||
if (opts->topic.len > 0) { // allow zero-length msgs, message.len is size_t
|
||||
total_len += 4 + (uint32_t) opts->topic.len + (uint32_t) opts->message.len;
|
||||
hdr[7] |= MQTT_HAS_WILL;
|
||||
}
|
||||
|
@ -277,7 +277,7 @@ void mg_mqtt_login(struct mg_connection *c, const struct mg_mqtt_opts *opts) {
|
||||
total_len += 2 + (uint32_t) opts->pass.len;
|
||||
hdr[7] |= MQTT_HAS_PASSWORD;
|
||||
}
|
||||
if (opts->topic.len > 0 && opts->message.len > 0) {
|
||||
if (opts->topic.len > 0) { // allow zero-length msgs, message.len is size_t
|
||||
total_len += 4 + (uint32_t) opts->topic.len + (uint32_t) opts->message.len;
|
||||
hdr[7] |= MQTT_HAS_WILL;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user