Skip to content

Commit b7195ce

Browse files
committed
libvncserver: move self-pipe check in client thread before any FD_ISSET
...and jump to loop start on encountering something in the self-pipe. Rationale is that on some platforms FD_ISSET(-1) triggers `FORTIFY: FD_ISSET: file descriptor -1 < 0`. This is the case on Android, for instance.
1 parent ce21406 commit b7195ce

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

libvncserver/main.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -571,20 +571,21 @@ clientInput(void *data)
571571
rfbSendFileTransferChunk(cl);
572572
continue;
573573
}
574-
575-
/* We have some space on the transmit queue, send some data */
576-
if (FD_ISSET(cl->sock, &wfds))
577-
rfbSendFileTransferChunk(cl);
578574

579575
#ifndef WIN32
580576
if (FD_ISSET(cl->pipe_notify_client_thread[0], &rfds))
581577
{
582578
/* Reset the pipe */
583579
char buf;
584580
while (read(cl->pipe_notify_client_thread[0], &buf, sizeof(buf)) == sizeof(buf));
581+
continue; /* Go on with loop */
585582
}
586583
#endif
587584

585+
/* We have some space on the transmit queue, send some data */
586+
if (FD_ISSET(cl->sock, &wfds))
587+
rfbSendFileTransferChunk(cl);
588+
588589
if (FD_ISSET(cl->sock, &rfds) || FD_ISSET(cl->sock, &efds))
589590
{
590591
#ifdef LIBVNCSERVER_WITH_WEBSOCKETS

0 commit comments

Comments
 (0)