summaryrefslogtreecommitdiff
path: root/ext/socket/ancdata.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-16 11:44:42 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-16 11:44:42 +0000
commit75a5be3717d15c468beccab2ba618b01f44d56ec (patch)
treec5a77076f4a1618ae5563f7fd16bd55a8ed5f00f /ext/socket/ancdata.c
parent1061371f29baabd89c60d2d364947015b928d794 (diff)
* ext/socket/ancdata.c (rsock_recvmsg): ignore truncated part of
socket address returned from recvmsg(). * ext/socket/init.c (recvfrom_blocking): ignore truncated part of socket address returned from recvfrom(). (rsock_s_recvfrom_nonblock): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39278 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket/ancdata.c')
-rw-r--r--ext/socket/ancdata.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/ext/socket/ancdata.c b/ext/socket/ancdata.c
index fa794eb..34a6185 100644
--- a/ext/socket/ancdata.c
+++ b/ext/socket/ancdata.c
@@ -1362,11 +1362,17 @@ struct recvmsg_args_struct {
ssize_t
rsock_recvmsg(int socket, struct msghdr *message, int flags)
{
+ ssize_t ret;
+ socklen_t len0;
#ifdef MSG_CMSG_CLOEXEC
/* MSG_CMSG_CLOEXEC is available since Linux 2.6.23. Linux 2.6.18 silently ignore it. */
flags |= MSG_CMSG_CLOEXEC;
#endif
- return recvmsg(socket, message, flags);
+ len0 = message->msg_namelen;
+ ret = recvmsg(socket, message, flags);
+ if (ret != -1 && len0 < message->msg_namelen)
+ message->msg_namelen = len0;
+ return ret;
}
static void *