Fix of decode length

This commit is contained in:
hsaturn
2021-08-09 10:35:49 +02:00
parent fab242e212
commit 9c7f3b6b8e
6 changed files with 70 additions and 4 deletions

View File

@@ -665,7 +665,12 @@ void MqttMessage::incoming(char in_byte)
state = Length;
break;
case Length:
size = (size<<7) + (in_byte & 0x7F);
if (size==0)
size = in_byte & 0x7F;
else if (size<128)
size += static_cast<uint16_t>(in_byte & 0x7F)<<7;
else
state = Error; // Really don't want to handle msg with length > 16k
if (size > MaxBufferLength)
{
state = Error;