[前][次][番号順一覧][スレッド一覧]

ruby-changes:43888

From: nagachika <ko1@a...>
Date: Thu, 18 Aug 2016 23:54:46 +0900 (JST)
Subject: [ruby-changes:43888] nagachika:r55961 (ruby_2_3): merge revision(s) 55822: [Backport #12660]

nagachika	2016-08-18 23:54:40 +0900 (Thu, 18 Aug 2016)

  New Revision: 55961

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55961

  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_3/
  Modified files:
    branches/ruby_2_3/ChangeLog
    branches/ruby_2_3/ext/openssl/ossl_ssl.c
    branches/ruby_2_3/test/openssl/test_pair.rb
    branches/ruby_2_3/version.h
Index: ruby_2_3/test/openssl/test_pair.rb
===================================================================
--- ruby_2_3/test/openssl/test_pair.rb	(revision 55960)
+++ ruby_2_3/test/openssl/test_pair.rb	(revision 55961)
@@ -280,6 +280,17 @@ module OpenSSL::TestPairM https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/openssl/test_pair.rb#L280
     }
   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_3/ChangeLog
===================================================================
--- ruby_2_3/ChangeLog	(revision 55960)
+++ ruby_2_3/ChangeLog	(revision 55961)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ChangeLog#L1
+Thu Aug 18 23:43:33 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]
+
 Thu Aug 18 23:18:17 2016  Nobuyoshi Nakada  <nobu@r...>
 
 	* ext/socket/option.c, ext/socket/rubysocket.h (inet_ntop): share
Index: ruby_2_3/ext/openssl/ossl_ssl.c
===================================================================
--- ruby_2_3/ext/openssl/ossl_ssl.c	(revision 55960)
+++ ruby_2_3/ext/openssl/ossl_ssl.c	(revision 55961)
@@ -1533,7 +1533,13 @@ ossl_ssl_write_internal(VALUE self, VALU https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ext/openssl/ossl_ssl.c#L1533
 
     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_3/version.h
===================================================================
--- ruby_2_3/version.h	(revision 55960)
+++ ruby_2_3/version.h	(revision 55961)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/version.h#L1
 #define RUBY_VERSION "2.3.2"
 #define RUBY_RELEASE_DATE "2016-08-18"
-#define RUBY_PATCHLEVEL 172
+#define RUBY_PATCHLEVEL 173
 
 #define RUBY_RELEASE_YEAR 2016
 #define RUBY_RELEASE_MONTH 8

Property changes on: ruby_2_3
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r55822


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]