aboutsummaryrefslogtreecommitdiffstats
path: root/test/socket
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-05-30 07:28:55 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-05-30 07:28:55 +0000
commit157f4f8bd6be81a0131c372da0e7de31e9fe297d (patch)
tree68b97807dc9950dce7af0642722b1378559ba8ec /test/socket
parent6d7e62a7238cfabc30f675002e14734be6c234a3 (diff)
downloadruby-157f4f8bd6be81a0131c372da0e7de31e9fe297d.tar.gz
raddrinfo.c: fix for SHARABLE_MIDDLE_SUBSTRING
* ext/socket/raddrinfo.c (host_str, port_str): use RSTRING_LEN instead of strlen, since RSTRING_PTR StringValueCStr may not be NUL-terminated when SHARABLE_MIDDLE_SUBSTRING=1. reported by @tmtms, http://twitter.com/tmtms/status/736910516229005312 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/socket')
-rw-r--r--test/socket/test_addrinfo.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/socket/test_addrinfo.rb b/test/socket/test_addrinfo.rb
index 9908278bbd..9084a604ed 100644
--- a/test/socket/test_addrinfo.rb
+++ b/test/socket/test_addrinfo.rb
@@ -35,6 +35,11 @@ class TestSocketAddrinfo < Test::Unit::TestCase
ai = Addrinfo.ip("<broadcast>")
assert_equal([0, "255.255.255.255"], Socket.unpack_sockaddr_in(ai))
+
+ ai = assert_nothing_raised(SocketError) do
+ Addrinfo.ip("00000000127.000000000.00000000.0000001x".chop)
+ end
+ assert_equal([0, "127.0.0.1"], Socket.unpack_sockaddr_in(ai))
end
def test_addrinfo_tcp
@@ -44,6 +49,11 @@ class TestSocketAddrinfo < Test::Unit::TestCase
assert_equal(Socket::PF_INET, ai.pfamily)
assert_equal(Socket::SOCK_STREAM, ai.socktype)
assert_include([0, Socket::IPPROTO_TCP], ai.protocol)
+
+ ai = assert_nothing_raised(SocketError) do
+ Addrinfo.tcp("127.0.0.1", "0000000000000000000000080x".chop)
+ end
+ assert_equal([80, "127.0.0.1"], Socket.unpack_sockaddr_in(ai))
end
def test_addrinfo_udp