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

Crash of mosquitto broker on Windows when client disconnects from websocket connection #1137

Closed
krismattheus opened this issue Feb 1, 2019 · 1 comment
Milestone

Comments

@krismattheus
Copy link
Contributor

There is a bug in the callback_mqtt function in websockets.c, that causes a crash of the mosquitto broker on Windows when a client closes its websocket connection.

if(mosq->sock > 0){
should be changed to:

if((int)mosq->sock > 0){
or
if(mosq->sock != INVALID_SOCKET){

A socket on Windows is an unsigned int, so this test succeeds even when the value is INVALID_SOCKET.
This invalid test causes the HASH_DELETE to be called again when the socket is already closed. This causes the crash. After changing the code the crash no longer happens.

Some extra info:
We use mosquitto version 1.5.5 and libwebsockets 3.0.1

@ralight ralight added this to the 1.5.6 milestone Feb 2, 2019
@ralight
Copy link
Contributor

ralight commented Feb 2, 2019

Thanks, that's fixed in my local branch and will be pushed as part of 1.5.6 shortly.

@ralight ralight closed this as completed Feb 2, 2019
ralight added a commit that referenced this issue Feb 8, 2019
ralight added a commit that referenced this issue Apr 25, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Aug 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants