Commit ab806ebc authored by Pavel Emelyanov's avatar Pavel Emelyanov

scm: Check for cmsg not to be truncated when receiving fds

Otherwise we can get stuck waiting for more data in vain.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 5e95df84
...@@ -102,6 +102,8 @@ int recv_fds(int sock, int *fds, int nr_fds, char *flags) ...@@ -102,6 +102,8 @@ int recv_fds(int sock, int *fds, int nr_fds, char *flags)
cmsg = CMSG_FIRSTHDR(&fdset.hdr); cmsg = CMSG_FIRSTHDR(&fdset.hdr);
if (!cmsg || cmsg->cmsg_type != SCM_RIGHTS) if (!cmsg || cmsg->cmsg_type != SCM_RIGHTS)
return -EINVAL; return -EINVAL;
if (fdset.hdr.msg_flags & MSG_CTRUNC)
return -ENFILE;
min_fd = (cmsg->cmsg_len - sizeof(struct cmsghdr)) / sizeof(int); min_fd = (cmsg->cmsg_len - sizeof(struct cmsghdr)) / sizeof(int);
/* /*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment