From 09243d55ae58610a3d80b9245534a805a4ad3b64 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 6 Apr 2021 11:26:02 +0200 Subject: [PATCH] pulse-server: fix leak in flatpak detection --- src/modules/module-protocol-pulse/pulse-server.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/modules/module-protocol-pulse/pulse-server.c b/src/modules/module-protocol-pulse/pulse-server.c index c036cf0f5..e64396805 100644 --- a/src/modules/module-protocol-pulse/pulse-server.c +++ b/src/modules/module-protocol-pulse/pulse-server.c @@ -5823,7 +5823,7 @@ static int check_flatpak(struct client *client, int pid) struct stat stat_buf; sprintf(root_path, "/proc/%u/root", pid); - root_fd = openat (AT_FDCWD, root_path, O_RDONLY | O_NONBLOCK | O_DIRECTORY | O_CLOEXEC | O_NOCTTY); + root_fd = openat(AT_FDCWD, root_path, O_RDONLY | O_NONBLOCK | O_DIRECTORY | O_CLOEXEC | O_NOCTTY); if (root_fd == -1) { res = -errno; if (res == -EACCES) { @@ -5842,8 +5842,8 @@ static int check_flatpak(struct client *client, int pid) pw_log_info("failed to open \"%s\": %s", root_path, spa_strerror(res)); return res; } - info_fd = openat (root_fd, ".flatpak-info", O_RDONLY | O_CLOEXEC | O_NOCTTY); - close (root_fd); + info_fd = openat(root_fd, ".flatpak-info", O_RDONLY | O_CLOEXEC | O_NOCTTY); + close(root_fd); if (info_fd == -1) { if (errno == ENOENT) { pw_log_debug("no .flatpak-info, client on the host"); @@ -5854,11 +5854,11 @@ static int check_flatpak(struct client *client, int pid) pw_log_error("error opening .flatpak-info: %m"); return res; } - if (fstat (info_fd, &stat_buf) != 0 || !S_ISREG (stat_buf.st_mode)) { + if (fstat(info_fd, &stat_buf) != 0 || !S_ISREG(stat_buf.st_mode)) { /* Some weird fd => failure, assume sandboxed */ - close(info_fd); pw_log_error("error fstat .flatpak-info: %m"); } + close(info_fd); return 1; }