aboutsummaryrefslogtreecommitdiffhomepage
path: root/backends/mqtt.c
diff options
context:
space:
mode:
Diffstat (limited to 'backends/mqtt.c')
-rw-r--r--backends/mqtt.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/backends/mqtt.c b/backends/mqtt.c
index f2a7c83..47042f1 100644
--- a/backends/mqtt.c
+++ b/backends/mqtt.c
@@ -775,14 +775,15 @@ static int mqtt_handle_publish(instance* inst, uint8_t type, uint8_t* variable_h
property_offset += mqtt_pop_varint(variable_header + property_offset, length - property_offset, NULL);
//parse properties
- while(property_offset < payload_offset){
+ while(property_offset < payload_offset && property_offset < length){
DBGPF("Property %02X at offset %" PRIsize_t " of %" PRIu32, variable_header[property_offset], property_offset, property_length);
+
//read payload format indicator
- if(variable_header[property_offset] == 0x01){
+ if(variable_header[property_offset] == 0x01 && property_offset < length - 1){
content_utf8 = variable_header[property_offset + 1];
}
//read topic alias
- else if(variable_header[property_offset] == 0x23){
+ else if(variable_header[property_offset] == 0x23 && property_offset < length - 2){
topic_alias = (variable_header[property_offset + 1] << 8) | variable_header[property_offset + 2];
}