Permalink
Browse files

Fix remaining length protection

  • Loading branch information...
knolleary committed Nov 2, 2018
1 parent af86013 commit 4daba0ae5c11cca4da2fd98a1ba4fe0b490a4a86
Showing with 3 additions and 3 deletions.
  1. +1 −1 src/PubSubClient.cpp
  2. +2 −2 tests/src/receive_spec.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();
@@ -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();

0 comments on commit 4daba0a

Please sign in to comment.