readInt in MQTTPacket.c returns badness
december1981 opened this issue · 3 comments
december1981 commented
This fixed it for me. Otherwise, what should return, say, 128 ends up returning -128, because of anomolous sign extension from the lower byte of the integer.
--- a/src/MQTTPacket.c
+++ b/src/MQTTPacket.c
@@ -362,7 +362,7 @@ exit:
int readInt(char** pptr)
{
char *ptr = *pptr;
- int val = ((((uint32_t)ptr[0]) << 8) | ((uint32_t)ptr[1]));
+ int val = ((((uint32_t)ptr[0]) << 8) | (uint8_t)ptr[1]);
*pptr += 2;
return val;
}
icraggs commented
I've reverted that PR, so hopefully should work now.
december1981 commented
Then I'll close this