Fix casting issue in MQTT parsing

This commit is contained in:
robert committed 2026-05-07 09:30:03 -04:00
1 parent eee8c7077c
commit d44b9b9adf
3 files changed
+33 -30

No files matched your search

+13
View File
@@ -787,12 +787,25 @@ static void test_mqtt_ver(uint8_t mqtt_version) {
ASSERT(mgr.conns == NULL);
}
static void test_mqtt_parse(void) {
struct mg_mqtt_message mm;
struct mg_mqtt_prop prop;
// MQTT5 PUBLISH with Subscription Identifier = 5
const uint8_t sub_id_pkt[] = {0x30, 0x06, 0x00, 0x01, 'x', 0x02, 0x0B, 0x05};
memset(&mm, 0, sizeof(struct mg_mqtt_message));
memset(&prop, 0, sizeof(struct mg_mqtt_prop));
ASSERT(mg_mqtt_parse(sub_id_pkt, sizeof(sub_id_pkt), 5, &mm) == MQTT_OK);
mg_mqtt_next_prop(&mm, &prop, 0);
}
static void test_mqtt(void) {
test_mqtt_base();
#ifdef NO_MQTT_TESTS
MG_ERROR(("MQTT tests skipped on request"));
(void) test_mqtt_basic, (void) test_mqtt_ver;
#else
test_mqtt_parse();
test_mqtt_basic();
test_mqtt_ver(4);
test_mqtt_ver(5);