From 60bdf1aa7627844dffed83163df57a1e20def803 Mon Sep 17 00:00:00 2001 From: David Garske Date: Tue, 21 Nov 2023 11:56:22 -0800 Subject: [PATCH] Fix for read of fixed portion (2 bytes) of header when only 1 is returned. --- src/mqtt_client.c | 3 ++- src/mqtt_packet.c | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mqtt_client.c b/src/mqtt_client.c index a13c64325..f284b0207 100644 --- a/src/mqtt_client.c +++ b/src/mqtt_client.c @@ -1087,7 +1087,8 @@ static int MqttClient_WaitType(MqttClient *client, void *packet_obj, if (rc <= 0) { #ifdef WOLFMQTT_NONBLOCK if (rc == MQTT_CODE_CONTINUE && - client->packet.stat > MQTT_PK_BEGIN) { + (client->packet.stat > MQTT_PK_BEGIN || + client->read.total > 0)) { /* advance state, since we received some data */ mms_stat->read = MQTT_MSG_HEADER; } diff --git a/src/mqtt_packet.c b/src/mqtt_packet.c index cafa8e842..1b9fd0008 100644 --- a/src/mqtt_packet.c +++ b/src/mqtt_packet.c @@ -1963,7 +1963,6 @@ int MqttPacket_Read(MqttClient *client, byte* rx_buf, int rx_buf_len, { case MQTT_PK_BEGIN: { - client->read.pos = 0; client->packet.header_len = MQTT_PACKET_HEADER_MIN_SIZE; client->packet.remain_len = 0;