Add check for truncated control message

Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
Matthieu Herrb 2012-10-07 12:05:26 -07:00 committed by Keith Packard
parent fb29490270
commit d4d31cd5f1
1 changed files with 5 additions and 0 deletions

View File

@ -45,6 +45,11 @@ sock_fd_read(int sock, void *buf, ssize_t bufsize, int *fd)
perror ("recvmsg");
exit(1);
}
if ((msg.msg_flags & MSG_TRUNC) ||
(msg.msg_flags & MSG_CTRUNC)) {
fprintf (stderr, "control message truncated");
exit(1);
}
cmsg = CMSG_FIRSTHDR(&msg);
if (cmsg && cmsg->cmsg_len == CMSG_LEN(sizeof(int))) {
if (cmsg->cmsg_level != SOL_SOCKET) {