-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
On 32-bit systems UINT32_MAX properties aren't handled correctly #1336
Comments
Which structure? The MQTTProperty structure in MQTTProperties.h has them unsigned. However, the MQTTProperties_getNumericValue function returns an int rather than an unsigned int. |
I see this in MQTTProperty_write in writeInt4. As that takes an int, it'll end up being -1 in writeInt4 so (-1/ 16777216) is 0 and same with the other functions in there. I think either change that to unsigned int or to change it to (anInt >> 24) & 0xFF and so on for the rest of the values |
I have fixed this issue |
So I think that writeInt4 and readInt4 should definitely be changed to take and return unsigned ints respectively. I'll make that change. @Zephyrus29 can you try out the PR from @zhizhi-dev and see if it works for you? Thanks. |
I've reverted Pr #1327 because of errors created. writeInt4 and readInt4 have been changed to take and return an unsigned int, rather than an int, so that might help. That might work - if anyone can try it out I'd appreciate it (lack of 32-bit environment easy to get to). |
** Description **
MQTT properties such as the session expiry are not handled correctly if they're set to UINT32_MAX. This is due to them being handled as an int instead of an unsigned int.
To Reproduce
On a 32-bit system set MQTTPROPERTY_CODE_SESSION_EXPIRY_INTERVAL to UINT32_MAX
Record the session expiry from the broker, it will be 0xFF
Expected behavior
Should pass up 0xFFFFFFFF instead of 0xFF
Additional context
Should use uint32_t instead of int in the properties struct
The text was updated successfully, but these errors were encountered: