mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-06 13:30:01 -05:00
Make sure we don't read too much
This commit is contained in:
parent
236ebeeb68
commit
ce98162ed2
2 changed files with 5 additions and 3 deletions
|
|
@ -53,6 +53,7 @@ struct impl {
|
|||
static int check_cmdline(struct pw_impl_client *client, int pid, const char *str)
|
||||
{
|
||||
char path[2048];
|
||||
ssize_t len;
|
||||
int fd;
|
||||
|
||||
sprintf(path, "/proc/%u/cmdline", pid);
|
||||
|
|
@ -61,10 +62,11 @@ static int check_cmdline(struct pw_impl_client *client, int pid, const char *str
|
|||
if (fd < 0)
|
||||
return -errno;
|
||||
|
||||
if (read(fd, path, 1024) <= 0) {
|
||||
if ((len = read(fd, path, sizeof(path)-1)) < 0) {
|
||||
close(fd);
|
||||
return -EIO;
|
||||
return -errno;
|
||||
}
|
||||
path[len] = '\0';
|
||||
|
||||
if (strcmp(path, str) == 0) {
|
||||
close(fd);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue