Skip to content

Commit 4c15a85

Browse files
vaplvVincent Forest
andauthored
libvncclient: fix the fork()ing listening for incoming connections
listenForIncomingConnections() uses a socket declared as a local variable, whereas accepting used an uninitialized client member variable. Note that the use of a local variable is necessary because the pointer to the client is invalid in the child process. The problem was highlighted with x11vnc when running a VNC repeater (x11vnc -reflect listen:5500) waiting for an incoming connection from a VNC server (x11vnc -connect IP.ADDRESS.OF.REPEATER). When an incoming connection request was submitted, the repeater did not accept it and returned an error. The regression was introduced by 75bfb1f Co-authored-by: Vincent Forest <vincent.forest@meso-star.com>
1 parent e64fa92 commit 4c15a85

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/libvncclient/listen.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ listenForIncomingConnections(rfbClient* client)
103103

104104
if (r > 0) {
105105
if (listenSocket != RFB_INVALID_SOCKET && FD_ISSET(listenSocket, &fds))
106-
client->sock = AcceptTcpConnection(client->listenSock);
106+
client->sock = AcceptTcpConnection(listenSocket);
107107
else if (listen6Socket != RFB_INVALID_SOCKET && FD_ISSET(listen6Socket, &fds))
108-
client->sock = AcceptTcpConnection(client->listen6Sock);
108+
client->sock = AcceptTcpConnection(listen6Socket);
109109

110110
if (client->sock == RFB_INVALID_SOCKET)
111111
return;

0 commit comments

Comments
 (0)