module-access: don't leak the fd in check_cmdline

This commit is contained in:
George Kiagiadakis 2019-02-13 13:22:07 +02:00 committed by Wim Taymans
parent 2340ae40a8
commit 7a7a12138f

View file

@ -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;
}