File tree Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -564,21 +564,23 @@ Adafruit_MQTT_Subscribe *Adafruit_MQTT::handleSubscriptionPacket(uint16_t len) {
564
564
565
565
// Parse MQTT Remaining Length field (variable length encoding).
566
566
// This field can be 1-4 bytes, so we must parse it byte-by-byte.
567
- // Each byte uses the lower 7 bits for data, and the MSB as a continuation flag.
568
- // This loop advances 'offset' to the first byte after the remaining length field.
567
+ // Each byte uses the lower 7 bits for data, and the MSB as a continuation
568
+ // flag. This loop advances 'offset' to the first byte after the remaining
569
+ // length field.
569
570
uint32_t multiplier = 1 ;
570
571
uint32_t value = 0 ;
571
572
uint8_t encodedByte;
572
573
uint8_t offset = 1 ; // Start after the fixed header byte
573
574
do {
574
- encodedByte = buffer[offset++];
575
- value += (encodedByte & 127 ) * multiplier;
576
- multiplier *= 128 ;
577
- // Infinite loop protection: MQTT spec allows max 4 bytes for this field
578
- if (offset > 5 ) { // 1 (header) + 4 (max length bytes)
579
- DEBUG_PRINTLN (F (" Bad MQTT packet: Remaining Length field too long / malformed" ));
580
- return NULL ;
581
- }
575
+ encodedByte = buffer[offset++];
576
+ value += (encodedByte & 127 ) * multiplier;
577
+ multiplier *= 128 ;
578
+ // Infinite loop protection: MQTT spec allows max 4 bytes for this field
579
+ if (offset > 5 ) { // 1 (header) + 4 (max length bytes)
580
+ DEBUG_PRINTLN (
581
+ F (" Bad MQTT packet: Remaining Length field too long / malformed" ));
582
+ return NULL ;
583
+ }
582
584
} while ((encodedByte & 128 ) != 0 );
583
585
584
586
// Now 'offset' points to the first byte of the topic length field.
You can’t perform that action at this time.
0 commit comments