Skip to content

Commit 06cff31

Browse files
committed
libvncserver: mitigate FORTIFY crash in listenerRun()
With the previous commit acac779 the select() call now times out, opening up for a race condition where rfbShutdownSockets() would set the listening sockets to -1, the select would time out and the FD_ISSET() call encounter a -1 socket. This is not 100% threadsafe but better than before.
1 parent acac779 commit 06cff31

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/libvncserver/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -668,9 +668,9 @@ listenerRun(void *data)
668668

669669
/* If there is something on the listening sockets, handle new connections */
670670
len = sizeof (peer);
671-
if (FD_ISSET(screen->listenSock, &listen_fds))
671+
if (screen->listenSock != RFB_INVALID_SOCKET && FD_ISSET(screen->listenSock, &listen_fds))
672672
client_fd = accept(screen->listenSock, (struct sockaddr*)&peer, &len);
673-
else if (FD_ISSET(screen->listen6Sock, &listen_fds))
673+
else if (screen->listen6Sock != RFB_INVALID_SOCKET && FD_ISSET(screen->listen6Sock, &listen_fds))
674674
client_fd = accept(screen->listen6Sock, (struct sockaddr*)&peer, &len);
675675

676676
if(client_fd >= 0)

0 commit comments

Comments
 (0)