fixed Reset on message with empty data

develop
Tuan PM 2015-01-17 09:30:36 +07:00
rodzic f1f71329dc
commit 63eff771c8
2 zmienionych plików z 4 dodań i 3 usunięć

Wyświetl plik

@ -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);

Wyświetl plik

@ -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)