From 1417cb1c3f19de906074983bd98caee5283cb006 Mon Sep 17 00:00:00 2001 From: George Fleury Date: Fri, 13 May 2016 06:01:43 -0300 Subject: [PATCH] Avoid calling SSL_pending when connection is already closed Avoid calling SSL_pending when connection is already closed, calling SSL_pending with connection already closed is crashing. To reproduce, open a secure websocket binay protocol connection with libvncserver compiled with OpenSSL, and when libvncserver is waiting for rfbProcessClientProtocolVersion send any invalid char, it will fail and call rfbCloseClient whith destroy all SSL context, calling SSL_pending after that will generate a invalid access. --- libvncserver/sockets.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libvncserver/sockets.c b/libvncserver/sockets.c index e960936..51e86eb 100644 --- a/libvncserver/sockets.c +++ b/libvncserver/sockets.c @@ -394,7 +394,7 @@ rfbCheckFds(rfbScreenInfoPtr rfbScreen,long usec) #ifdef LIBVNCSERVER_WITH_WEBSOCKETS do { rfbProcessClientMessage(cl); - } while (webSocketsHasDataInBuffer(cl)); + } while (cl->sock > 0 && webSocketsHasDataInBuffer(cl)); #else rfbProcessClientMessage(cl); #endif