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

Comments

Projects
None yet
2 participants
@krismattheus
Copy link

krismattheus commented Feb 1, 2019

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

This comment has been minimized.

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 Feb 2, 2019

ralight added a commit that referenced this issue Feb 8, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment