kopia lustrzana https://github.com/martin-ger/esp_mqtt
fixed #19 Reset on message with empty data
rodzic
f1f71329dc
commit
63eff771c8
user
|
@ -102,7 +102,6 @@ deliver_publish(MQTT_Client* client, uint8_t* message, int length)
|
|||
|
||||
event_data.topic_length = length;
|
||||
event_data.topic = mqtt_get_publish_topic(message, &event_data.topic_length);
|
||||
|
||||
event_data.data_length = length;
|
||||
event_data.data = mqtt_get_publish_data(message, &event_data.data_length);
|
||||
|
||||
|
|
|
@ -167,7 +167,7 @@ const char* mqtt_get_publish_topic(uint8_t* buffer, uint16_t* length)
|
|||
topiclen = buffer[i++] << 8;
|
||||
topiclen |= buffer[i++];
|
||||
|
||||
if(i + topiclen >= *length)
|
||||
if(i + topiclen > *length)
|
||||
return NULL;
|
||||
|
||||
*length = topiclen;
|
||||
|
@ -196,8 +196,10 @@ const char* mqtt_get_publish_data(uint8_t* buffer, uint16_t* length)
|
|||
topiclen = buffer[i++] << 8;
|
||||
topiclen |= buffer[i++];
|
||||
|
||||
if(i + topiclen >= *length)
|
||||
if(i + topiclen >= *length){
|
||||
*length = 0;
|
||||
return NULL;
|
||||
}
|
||||
i += topiclen;
|
||||
|
||||
if(mqtt_get_qos(buffer) > 0)
|
||||
|
|
Ładowanie…
Reference in New Issue