From 70c6e6ccc84f64224fb9ecbe07b82ea372025076 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Mon, 31 May 2021 17:39:37 +0200 Subject: [PATCH] pulse-server: only unlink sockets If the entity specified in a unix socket address exists, check if it is a socket, and bail out if it is not. --- src/modules/module-protocol-pulse/pulse-server.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/modules/module-protocol-pulse/pulse-server.c b/src/modules/module-protocol-pulse/pulse-server.c index ea2201a04..a99381a26 100644 --- a/src/modules/module-protocol-pulse/pulse-server.c +++ b/src/modules/module-protocol-pulse/pulse-server.c @@ -5971,6 +5971,13 @@ static int start_unix_server(struct server *server, const struct sockaddr_storag } } else if (socket_stat.st_mode & S_IWUSR || socket_stat.st_mode & S_IWGRP) { + if (!S_ISSOCK(socket_stat.st_mode)) { + res = -EEXIST; + pw_log_warn(NAME" %p: '%s' exists and is not a socket", + server, addr_un->sun_path); + goto error_close; + } + /* socket is there, check if it's stale */ if (!is_stale_socket(fd, addr_un)) { res = -EADDRINUSE;