From 35693f7780ff22b78cb6e25986922e134717bfea Mon Sep 17 00:00:00 2001 From: robert Date: Thu, 14 May 2026 02:55:12 -0400 Subject: [PATCH] fix mqtt cast error --- mongoose.c | 6 +++--- src/mqtt.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mongoose.c b/mongoose.c index 4a805831..1f89851c 100644 --- a/mongoose.c +++ b/mongoose.c @@ -5921,7 +5921,7 @@ void mg_mqtt_unsub(struct mg_connection *c, const struct mg_mqtt_opts *opts) { int mg_mqtt_parse(const uint8_t *buf, size_t len, uint8_t version, struct mg_mqtt_message *m) { uint8_t lc = 0, *p, *end; - uint32_t n = 0, len_len = 0; + uint32_t n = 0, len_len = 0, tmp; memset(m, 0, sizeof(*m)); m->dgram.buf = (char *) buf; @@ -5972,9 +5972,9 @@ int mg_mqtt_parse(const uint8_t *buf, size_t len, uint8_t version, } if (p > end) return MQTT_MALFORMED; if (version == 5 && p + 2 < end) { - len_len = (uint32_t) decode_varint(p, (size_t) (end - p), - (uint32_t *) &m->props_size); + len_len = (uint32_t) decode_varint(p, (size_t) (end - p), &tmp); if (!len_len) return MQTT_MALFORMED; + m->props_size = (size_t) tmp; m->props_start = (size_t) (p + len_len - buf); p += len_len + m->props_size; } diff --git a/src/mqtt.c b/src/mqtt.c index 29cf2570..57f5fae7 100644 --- a/src/mqtt.c +++ b/src/mqtt.c @@ -409,7 +409,7 @@ void mg_mqtt_unsub(struct mg_connection *c, const struct mg_mqtt_opts *opts) { int mg_mqtt_parse(const uint8_t *buf, size_t len, uint8_t version, struct mg_mqtt_message *m) { uint8_t lc = 0, *p, *end; - uint32_t n = 0, len_len = 0; + uint32_t n = 0, len_len = 0, tmp; memset(m, 0, sizeof(*m)); m->dgram.buf = (char *) buf; @@ -460,9 +460,9 @@ int mg_mqtt_parse(const uint8_t *buf, size_t len, uint8_t version, } if (p > end) return MQTT_MALFORMED; if (version == 5 && p + 2 < end) { - len_len = (uint32_t) decode_varint(p, (size_t) (end - p), - (uint32_t *) &m->props_size); + len_len = (uint32_t) decode_varint(p, (size_t) (end - p), &tmp); if (!len_len) return MQTT_MALFORMED; + m->props_size = (size_t) tmp; m->props_start = (size_t) (p + len_len - buf); p += len_len + m->props_size; }