You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi everyone, hi Ian
I happened to have found a bug in my MQTTPacket.c non-blocking
functions, particularly the one that extracts the message length:
MQTTPacket_decodenb()
On really slow links, if TCP (or whatever underlying transport) fails to
provide the whole length bytes before this function is called 4 times,
next call will exit with an error code. The problem is that the function
is also counting "additional entries" in addition to properly counting
received bytes.
Correction is attached: correctdecodenb.zip
Basically:
diff --git a/MQTTPacket/src/MQTTPacket.c b/MQTTPacket/src/MQTTPacket.c
index bd5f90a..e4746cd 100644
--- a/MQTTPacket/src/MQTTPacket.c
+++ b/MQTTPacket/src/MQTTPacket.c
@@ -333,14 +333,15 @@ static int MQTTPacket_decodenb(MQTTTransport *trp)
}
do {
int frc;
- if (++(trp->len) > MAX_NO_OF_REMAINING_LENGTH_BYTES)
+ if (trp->len >= MAX_NO_OF_REMAINING_LENGTH_BYTES)
goto exit;
if ((frc=(*trp->getfn)(trp->sck, &c, 1)) == -1)
goto exit;
if (frc == 0){
rc = 0;
goto exit;
- }
+ }
+ ++(trp->len);
trp->rem_len += (c & 127) * trp->multiplier;
trp->multiplier *= 128;
} while ((c & 128) != 0);
PS: This bug hunting has been done as part of a project ending nov 30th, which will also provide new samples and a serial transport to Paho MQTT. See you later guys.
The text was updated successfully, but these errors were encountered:
Hi everyone, hi Ian
I happened to have found a bug in my MQTTPacket.c non-blocking
functions, particularly the one that extracts the message length:
MQTTPacket_decodenb()
On really slow links, if TCP (or whatever underlying transport) fails to
provide the whole length bytes before this function is called 4 times,
next call will exit with an error code. The problem is that the function
is also counting "additional entries" in addition to properly counting
received bytes.
Correction is attached: correctdecodenb.zip
Basically:
PS: This bug hunting has been done as part of a project ending nov 30th, which will also provide new samples and a serial transport to Paho MQTT. See you later guys.
The text was updated successfully, but these errors were encountered: