diff options
Diffstat (limited to 'ext/socket/socket.c')
-rw-r--r-- | ext/socket/socket.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/ext/socket/socket.c b/ext/socket/socket.c index 2f7a07f864..a8b53bd534 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -2118,9 +2118,14 @@ unix_recv_io(int argc, VALUE *argv, VALUE sock) rb_sys_fail("recvmsg(2)"); #if FD_PASSING_BY_MSG_CONTROL - if (arg.msg.msg_controllen != CMSG_SPACE(sizeof(int))) { + if (arg.msg.msg_controllen < CMSG_LEN(sizeof(int))) { rb_raise(rb_eSocket, - "file descriptor was not passed (msg_controllen=%d, %d expected)", + "file descriptor was not passed (msg_controllen=%d smaller than CMSG_LEN(sizeof(int))=%d)", + (int)arg.msg.msg_controllen, (int)CMSG_LEN(sizeof(int))); + } + if (CMSG_SPACE(sizeof(int)) < arg.msg.msg_controllen) { + rb_raise(rb_eSocket, + "file descriptor was not passed (msg_controllen=%d bigger than CMSG_SPACE(sizeof(int))=%d)", (int)arg.msg.msg_controllen, (int)CMSG_SPACE(sizeof(int))); } if (cmsg.hdr.cmsg_len != CMSG_LEN(sizeof(int))) { |