FreeRTOS / coreMQTT

Client implementation of the MQTT 3.1.1 specification for embedded devices
MIT License
140 stars 100 forks source link

Fix time comparison overflow #288

Closed archigup closed 4 months ago

archigup commented 4 months ago

Fix time comparison in sendBuffer after overflow

Description

Fixes https://github.com/FreeRTOS/coreMQTT/issues/286

Previously, a time overflow could cause the comparison to fail, and cause a failed sendBuffer. Now, the code compares against the duration rather than against the specific timepoint. Since signed overflow/underflow is defined, subtracting to get the duration is okay as long as the duration fits in the integer type.

Test Steps

Checklist:

Related Issue

https://github.com/FreeRTOS/coreMQTT/issues/286

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.