2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-30 13:58:34 +00:00

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 <xemul@parallels.com>
This commit is contained in:
Pavel Emelyanov
2012-08-21 19:40:10 +04:00
parent 5e95df84f9
commit ab806ebc03

View File

@@ -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);
/*