[PATCH xserver] os: Call FlushClient() before sending FD-passing messages

Alexander Volkov a.volkov at rusbitech.ru
Fri Mar 30 11:18:55 UTC 2018


Otherwise a client may receive data with an unrelated file
descriptor after calling recvmsg() if its input buffer is not
big enough. In libxcb it may lead to a situation when all
received messages fit the buffer while a message related to
the attached fd is not received yet. libxcb can't find the
corresponding message and fails with XCB_CONN_CLOSED_FDPASSING_FAILED
error.
---
 os/io.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/os/io.c b/os/io.c
index b099f0967..f4e80557d 100644
--- a/os/io.c
+++ b/os/io.c
@@ -488,6 +488,9 @@ WriteFdToClient(ClientPtr client, int fd, Bool do_close)
 #if XTRANS_SEND_FDS
     OsCommPtr oc = (OsCommPtr) client->osPrivate;
 
+    if (oc->output && oc->output->count > 0)
+        (void) FlushClient(client, oc, (char *) NULL, 0);
+
     return _XSERVTransSendFd(oc->trans_conn, fd, do_close);
 #else
     return -1;
-- 
2.11.0



More information about the xorg-devel mailing list