diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-05-30 07:28:55 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-05-30 07:28:55 +0000 |
commit | 94a91b1d60d048dcf75039d6d64ad9ee7e5929f4 (patch) | |
tree | 68b97807dc9950dce7af0642722b1378559ba8ec /test/socket | |
parent | 79a85b18cc6ad27f1a70a703270680dc30a1263e (diff) | |
download | ruby-94a91b1d60d048dcf75039d6d64ad9ee7e5929f4.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.rb | 10 |
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 |