From 7a7a12138fb3818ac7ca3445f657ec460cf7d9c0 Mon Sep 17 00:00:00 2001 From: George Kiagiadakis Date: Wed, 13 Feb 2019 13:22:07 +0200 Subject: [PATCH] module-access: don't leak the fd in check_cmdline --- src/modules/module-access.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/modules/module-access.c b/src/modules/module-access.c index f81269cc4..5693b9b01 100644 --- a/src/modules/module-access.c +++ b/src/modules/module-access.c @@ -59,12 +59,17 @@ static int check_cmdline(struct pw_client *client, const struct ucred *ucred, co if (fd < 0) return -errno; - if (read(fd, path, 1024) <= 0) + if (read(fd, path, 1024) <= 0) { + close(fd); return -EIO; + } - if (strcmp(path, str) == 0) + if (strcmp(path, str) == 0) { + close(fd); return 1; + } + close(fd); return 0; }