From ab806ebc0374b355a56e88675b254b8bd072868c Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Tue, 21 Aug 2012 19:40:10 +0400 Subject: [PATCH] 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: Pavel Emelyanov --- util-net.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/util-net.c b/util-net.c index 090a8d7e7..f88e27d50 100644 --- a/util-net.c +++ b/util-net.c @@ -102,6 +102,8 @@ int recv_fds(int sock, int *fds, int nr_fds, char *flags) cmsg = CMSG_FIRSTHDR(&fdset.hdr); if (!cmsg || cmsg->cmsg_type != SCM_RIGHTS) return -EINVAL; + if (fdset.hdr.msg_flags & MSG_CTRUNC) + return -ENFILE; min_fd = (cmsg->cmsg_len - sizeof(struct cmsghdr)) / sizeof(int); /*