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

Possible undefined behaviour/bad memory access after reconnect #150

Closed
perigoso opened this issue Dec 15, 2021 · 2 comments
Closed

Possible undefined behaviour/bad memory access after reconnect #150

perigoso opened this issue Dec 15, 2021 · 2 comments

Comments

@perigoso
Copy link
Contributor

If within the reconnect callback something fails, and the function returns without correctly initializing the socket and calling connect, the sync continues as if nothing wrong happened, in cases where the socket initialization failed this could mean bad memory accesses in recv

A fix is included in #149

perigoso added a commit to aj-tec/MQTT-C that referenced this issue Dec 15, 2021
Signed-off-by: Rafael Silva <[email protected]>
perigoso added a commit to aj-tec/MQTT-C that referenced this issue Dec 17, 2021
Signed-off-by: Rafael Silva <[email protected]>
@brianrho
Copy link

brianrho commented Jan 28, 2022

Yeah, this really was an odd choice -- you've just gotten disconnected from the broker, what makes you so sure that your next reconnection, likely just seconds afterwards, will succeed? The reconnect_callback caller should've been able to deal with failures, without needing the callback itself to block until success.

Wonder if it'll be as simple as modifying the callback to return a bool and then an early return in mqtt_sync() if the callback fails.

@perigoso
Copy link
Contributor Author

Like i said i already provided a fix, tested and working on real world application

perigoso added a commit to aj-tec/MQTT-C that referenced this issue May 24, 2022
Signed-off-by: Rafael Silva <[email protected]>
LiamBindle added a commit that referenced this issue Jun 14, 2022
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

No branches or pull requests

2 participants