ruby-changes:44227
From: usa <ko1@a...>
Date: Sat, 1 Oct 2016 00:03:23 +0900 (JST)
Subject: [ruby-changes:44227] usa:r56300 (ruby_2_2): merge revision(s) 55822: [Backport #12660]
usa 2016-10-01 00:03:15 +0900 (Sat, 01 Oct 2016) New Revision: 56300 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56300 Log: merge revision(s) 55822: [Backport #12660] * ext/openssl/ossl_ssl.c (ossl_ssl_write_internal): avoid undefined behavior * test/openssl/test_pair.rb (test_write_zero): new test [ruby-core:76751] [Bug #12660] Modified directories: branches/ruby_2_2/ Modified files: branches/ruby_2_2/ChangeLog branches/ruby_2_2/ext/openssl/ossl_ssl.c branches/ruby_2_2/test/openssl/test_pair.rb branches/ruby_2_2/version.h Index: ruby_2_2/ChangeLog =================================================================== --- ruby_2_2/ChangeLog (revision 56299) +++ ruby_2_2/ChangeLog (revision 56300) @@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1 +Sat Oct 1 00:00:13 2016 Eric Wong <e@8...> + + * ext/openssl/ossl_ssl.c (ossl_ssl_write_internal): + avoid undefined behavior + * test/openssl/test_pair.rb (test_write_zero): new test + [ruby-core:76751] [Bug #12660] + Tue Aug 16 21:12:07 2016 Nobuyoshi Nakada <nobu@r...> * compile.c (ADD_TRACE): ignore trace instruction on non-positive Index: ruby_2_2/test/openssl/test_pair.rb =================================================================== --- ruby_2_2/test/openssl/test_pair.rb (revision 56299) +++ ruby_2_2/test/openssl/test_pair.rb (revision 56300) @@ -271,6 +271,17 @@ module OpenSSL::TestPairM https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/openssl/test_pair.rb#L271 } end + def test_write_zero + ssl_pair {|s1, s2| + assert_equal 0, s2.write_nonblock('', exception: false) + assert_kind_of Symbol, s1.read_nonblock(1, exception: false) + assert_equal 0, s2.syswrite('') + assert_kind_of Symbol, s1.read_nonblock(1, exception: false) + assert_equal 0, s2.write('') + assert_kind_of Symbol, s1.read_nonblock(1, exception: false) + } + end + def tcp_pair host = "127.0.0.1" serv = TCPServer.new(host, 0) Index: ruby_2_2/ext/openssl/ossl_ssl.c =================================================================== --- ruby_2_2/ext/openssl/ossl_ssl.c (revision 56299) +++ ruby_2_2/ext/openssl/ossl_ssl.c (revision 56300) @@ -1539,7 +1539,13 @@ ossl_ssl_write_internal(VALUE self, VALU https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ext/openssl/ossl_ssl.c#L1539 if (ssl) { for (;;){ - nwrite = SSL_write(ssl, RSTRING_PTR(str), RSTRING_LENINT(str)); + int num = RSTRING_LENINT(str); + + /* SSL_write(3ssl) manpage states num == 0 is undefined */ + if (num == 0) + goto end; + + nwrite = SSL_write(ssl, RSTRING_PTR(str), num); switch(ssl_get_error(ssl, nwrite)){ case SSL_ERROR_NONE: goto end; Index: ruby_2_2/version.h =================================================================== --- ruby_2_2/version.h (revision 56299) +++ ruby_2_2/version.h (revision 56300) @@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1 #define RUBY_VERSION "2.2.6" -#define RUBY_RELEASE_DATE "2016-08-16" -#define RUBY_PATCHLEVEL 369 +#define RUBY_RELEASE_DATE "2016-10-01" +#define RUBY_PATCHLEVEL 370 #define RUBY_RELEASE_YEAR 2016 -#define RUBY_RELEASE_MONTH 8 -#define RUBY_RELEASE_DAY 16 +#define RUBY_RELEASE_MONTH 10 +#define RUBY_RELEASE_DAY 1 #include "ruby/version.h" Property changes on: ruby_2_2 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r55822 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/