ruby-changes:50729
From: nagachika <ko1@a...>
Date: Fri, 23 Mar 2018 21:43:03 +0900 (JST)
Subject: [ruby-changes:50729] nagachika:r62904 (ruby_2_4): merge revision(s) 60162: [Backport #13994]
nagachika 2018-03-23 21:42:58 +0900 (Fri, 23 Mar 2018) New Revision: 62904 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62904 Log: merge revision(s) 60162: [Backport #13994] socket.c: null byte at Socket.getnameinfo * ext/socket/socket.c (sock_s_getnameinfo): check null byte. patched by tommy (Masahiro Tomita) in [ruby-dev:50286]. [Bug #13994] Modified directories: branches/ruby_2_4/ Modified files: branches/ruby_2_4/ext/socket/socket.c branches/ruby_2_4/test/socket/test_socket.rb branches/ruby_2_4/version.h Index: ruby_2_4/version.h =================================================================== --- ruby_2_4/version.h (revision 62903) +++ ruby_2_4/version.h (revision 62904) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/version.h#L1 #define RUBY_VERSION "2.4.4" #define RUBY_RELEASE_DATE "2018-03-23" -#define RUBY_PATCHLEVEL 283 +#define RUBY_PATCHLEVEL 284 #define RUBY_RELEASE_YEAR 2018 #define RUBY_RELEASE_MONTH 3 Index: ruby_2_4/ext/socket/socket.c =================================================================== --- ruby_2_4/ext/socket/socket.c (revision 62903) +++ ruby_2_4/ext/socket/socket.c (revision 62904) @@ -1287,7 +1287,7 @@ sock_s_getnameinfo(int argc, VALUE *argv https://github.com/ruby/ruby/blob/trunk/ruby_2_4/ext/socket/socket.c#L1287 hptr = NULL; } else { - strncpy(hbuf, StringValuePtr(host), sizeof(hbuf)); + strncpy(hbuf, StringValueCStr(host), sizeof(hbuf)); hbuf[sizeof(hbuf) - 1] = '\0'; hptr = hbuf; } @@ -1301,7 +1301,7 @@ sock_s_getnameinfo(int argc, VALUE *argv https://github.com/ruby/ruby/blob/trunk/ruby_2_4/ext/socket/socket.c#L1301 pptr = pbuf; } else { - strncpy(pbuf, StringValuePtr(port), sizeof(pbuf)); + strncpy(pbuf, StringValueCStr(port), sizeof(pbuf)); pbuf[sizeof(pbuf) - 1] = '\0'; pptr = pbuf; } Index: ruby_2_4/test/socket/test_socket.rb =================================================================== --- ruby_2_4/test/socket/test_socket.rb (revision 62903) +++ ruby_2_4/test/socket/test_socket.rb (revision 62904) @@ -105,6 +105,8 @@ class TestSocket < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_4/test/socket/test_socket.rb#L105 def test_getnameinfo assert_raise(SocketError) { Socket.getnameinfo(["AF_UNIX", 80, "0.0.0.0"]) } + assert_raise(ArgumentError) {Socket.getnameinfo(["AF_INET", "http\0", "example.net"])} + assert_raise(ArgumentError) {Socket.getnameinfo(["AF_INET", "http", "example.net\0"])} end def test_ip_address_list Index: ruby_2_4 =================================================================== --- ruby_2_4 (revision 62903) +++ ruby_2_4 (revision 62904) Property changes on: ruby_2_4 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /trunk:r60162 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/