diff --git a/src/PubSubClient.cpp b/src/PubSubClient.cpp index bd2514f..997bfb4 100755 --- a/src/PubSubClient.cpp +++ b/src/PubSubClient.cpp @@ -244,7 +244,7 @@ uint16_t PubSubClient::readPacket(uint8_t* lengthLength) { uint8_t start = 0; do { - if (len == 6) { + if (len == 5) { // Invalid remaining length encoding - kill the connection _state = MQTT_DISCONNECTED; _client->stop(); diff --git a/tests/src/receive_spec.cpp b/tests/src/receive_spec.cpp index 4ecd439..9a18af0 100644 --- a/tests/src/receive_spec.cpp +++ b/tests/src/receive_spec.cpp @@ -174,8 +174,8 @@ int test_drop_invalid_remaining_length_message() { int rc = client.connect((char*)"client_test1"); IS_TRUE(rc); - byte publish[] = {0x30,0x92,0x92,0x92,0x92,0x92,0x92,0x0,0x5,0x74,0x6f,0x70,0x69,0x63,0x70,0x61,0x79,0x6c,0x6f,0x61,0x64}; - shimClient.respond(publish,21); + byte publish[] = {0x30,0x92,0x92,0x92,0x92,0x01,0x0,0x5,0x74,0x6f,0x70,0x69,0x63,0x70,0x61,0x79,0x6c,0x6f,0x61,0x64}; + shimClient.respond(publish,20); rc = client.loop();