summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--ext/socket/ancdata.c2
-rw-r--r--ext/socket/lib/socket.rb4
-rw-r--r--test/socket/test_socket.rb16
4 files changed, 28 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index a3c8cbd47c4..273a8cb19f0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Wed Nov 18 06:59:52 2015 Eric Wong <e@80x24.org>
+
+ * ext/socket/ancdata.c (bsock_recvmsg_internal): grow buffer
+ on unspecified maxdatlen
+ [ruby-core:71517] [Bug #11701]
+ * ext/socket/lib/socket.rb (Socket#recvmsg): nil default for dlen
+ (Socket#recvmsg_nonblock): ditto
+ * test/socket/test_socket.rb (test_recvmsg_udp_no_arg): new test
+
Tue Nov 17 19:50:06 2015 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/win32.c (fstat): declare for mingw.
diff --git a/ext/socket/ancdata.c b/ext/socket/ancdata.c
index 168f70c3110..8fcd53c9fb2 100644
--- a/ext/socket/ancdata.c
+++ b/ext/socket/ancdata.c
@@ -1465,7 +1465,7 @@ bsock_recvmsg_internal(VALUE sock,
int gc_done = 0;
#endif
- maxdatlen = NUM2SIZET(vmaxdatlen);
+ maxdatlen = NIL_P(vmaxdatlen) ? 4061 : NUM2SIZET(vmaxdatlen);
#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
maxctllen = NIL_P(vmaxctllen) ? 4096 : NUM2SIZET(vmaxctllen);
#else
diff --git a/ext/socket/lib/socket.rb b/ext/socket/lib/socket.rb
index 58e7dfd92a7..0240c2094eb 100644
--- a/ext/socket/lib/socket.rb
+++ b/ext/socket/lib/socket.rb
@@ -425,7 +425,7 @@ class BasicSocket < IO
# return ancdata.unix_rights[0]
# end
# }
- def recvmsg(dlen = 4096, flags = 0, clen = nil, scm_rights: false)
+ def recvmsg(dlen = nil, flags = 0, clen = nil, scm_rights: false)
__recvmsg(dlen, flags, clen, scm_rights)
end
@@ -441,7 +441,7 @@ class BasicSocket < IO
# By specifying `exception: false`, the _opts_ hash allows you to indicate
# that recvmsg_nonblock should not raise an IO::WaitWritable exception, but
# return the symbol :wait_writable instead.
- def recvmsg_nonblock(dlen = 4096, flags = 0, clen = nil,
+ def recvmsg_nonblock(dlen = nil, flags = 0, clen = nil,
scm_rights: false, exception: true)
__recvmsg_nonblock(dlen, flags, clen, scm_rights, exception)
end
diff --git a/test/socket/test_socket.rb b/test/socket/test_socket.rb
index 26684622e2a..bfa4a143bfb 100644
--- a/test/socket/test_socket.rb
+++ b/test/socket/test_socket.rb
@@ -653,4 +653,20 @@ class TestSocket < Test::Unit::TestCase
end
end
+ def test_recvmsg_udp_no_arg
+ n = 4097
+ s1 = Addrinfo.udp("127.0.0.1", 0).bind
+ s2 = s1.connect_address.connect
+ s2.send("a" * n, 0)
+ ret = s1.recvmsg
+ assert_equal n, ret[0].bytesize, '[ruby-core:71517] [Bug #11701]'
+
+ s2.send("a" * n, 0)
+ IO.select([s1])
+ ret = s1.recvmsg_nonblock
+ assert_equal n, ret[0].bytesize, 'non-blocking should also grow'
+ ensure
+ s1.close
+ s2.close
+ end
end if defined?(Socket)