diff options
author | cbdev <cb@cbcdn.com> | 2021-06-23 22:27:15 +0200 |
---|---|---|
committer | cbdev <cb@cbcdn.com> | 2021-06-23 22:27:15 +0200 |
commit | a89dcd7942958e0ebe5881dde4820ceb77d29e9b (patch) | |
tree | a10e8de8265b61255a41261f0bfb6bceb40938f5 /backends/mqtt.c | |
parent | 6cfb87b2e1ce8e77563fdc9ac9b234808ad5acd0 (diff) | |
download | midimonster-a89dcd7942958e0ebe5881dde4820ceb77d29e9b.tar.gz midimonster-a89dcd7942958e0ebe5881dde4820ceb77d29e9b.tar.bz2 midimonster-a89dcd7942958e0ebe5881dde4820ceb77d29e9b.zip |
Fix build with recent environments, fix Coverity CID 371602 and 355842
Diffstat (limited to 'backends/mqtt.c')
-rw-r--r-- | backends/mqtt.c | 7 |
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]; } |