From de5bf64bfcbc57d7c6e20d11b568627e345bf872 Mon Sep 17 00:00:00 2001 From: Ilya Lukyanov Date: Fri, 4 Aug 2017 16:05:05 +0300 Subject: [PATCH] Make IPC client socket non-blocking This should prevent deadlocks with malicious clients --- sway/ipc-server.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sway/ipc-server.c b/sway/ipc-server.c index dca881fa5..df5aa1d2a 100644 --- a/sway/ipc-server.c +++ b/sway/ipc-server.c @@ -163,8 +163,8 @@ int ipc_handle_connection(int fd, uint32_t mask, void *data) { int flags; if ((flags = fcntl(client_fd, F_GETFD)) == -1 - || fcntl(client_fd, F_SETFD, flags|FD_CLOEXEC) == -1) { - sway_log_errno(L_ERROR, "Unable to set CLOEXEC on IPC client socket"); + || fcntl(client_fd, F_SETFD, flags|FD_CLOEXEC|O_NONBLOCK) == -1) { + sway_log_errno(L_ERROR, "Unable to set CLOEXEC|NONBLOCK on IPC client socket"); close(client_fd); return 0; }