Skip to content
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

sendBuffer may fail because of tick timer rollover #286

Closed
dtaarondecker opened this issue May 25, 2024 · 1 comment · Fixed by #288
Closed

sendBuffer may fail because of tick timer rollover #286

dtaarondecker opened this issue May 25, 2024 · 1 comment · Fixed by #288

Comments

@dtaarondecker
Copy link

dtaarondecker commented May 25, 2024

In core_mqtt.c, sendBuffer a timeout value is calculated by reading the current time and adding some timeout to that value.

timeoutMs = pContext->getTime() + MQTT_SEND_TIMEOUT_MS;

Take the case where current time is very close to, but not yet rolled over. We then add some timeout value causing a rollover on the timeoutMs variable.

We then check if the current time is greater than or equal to the timeout time

if( pContext->getTime() >= timeoutMs )

This check will erroneously fail.

For Example:

current time = 4294957296
timeoutMs = current time + 20000 = 20000

*continue executing*

Current Time = current time + ΔT where ΔT is less than 2^32 - current time 

currentTime >= timeoutMs = true until current time rolls over.
@paulbartell
Copy link
Contributor

@dtaarondecker Thanks for the bug report. If you would like, feel free to open a pull request fixing the issue. Otherwise, we will get to it soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants