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

ruby-changes:39385

From: normal <ko1@a...>
Date: Sun, 2 Aug 2015 07:08:44 +0900 (JST)
Subject: [ruby-changes:39385] normal:r51466 (trunk): openssl/buffering: fix gets on EOF with limit

normal	2015-08-02 07:08:17 +0900 (Sun, 02 Aug 2015)

  New Revision: 51466

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

  Log:
    openssl/buffering: fix gets on EOF with limit
    
    * ext/openssl/lib/openssl/buffering.rb (gets):
      avoid comparing fixnum with nil
    * test/openssl/test_pair.rb: test gets with limit when EOF is hit
      Thanks to Bar Hofesh <bar.hofesh@s...> for the bug report
      and testing.
      [ruby-core:70149] [Bug #11400]

  Modified files:
    trunk/ChangeLog
    trunk/ext/openssl/lib/openssl/buffering.rb
    trunk/test/openssl/test_pair.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 51465)
+++ ChangeLog	(revision 51466)
@@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Aug  2 07:01:17 2015  Eric Wong  <e@8...>
+
+	* ext/openssl/lib/openssl/buffering.rb (gets):
+	  avoid comparing fixnum with nil
+	* test/openssl/test_pair.rb: test gets with limit when EOF is hit
+	  Thanks to Bar Hofesh <bar.hofesh@s...> for the bug report
+	  and testing.
+	  [ruby-core:70149] [Bug #11400]
+
 Sat Aug  1 17:13:15 2015  Kazuki Tsujimoto  <kazuki@c...>
 
 	* lib/net/http/response.rb (Net::HTTPResponse::Inflater#finish):
Index: ext/openssl/lib/openssl/buffering.rb
===================================================================
--- ext/openssl/lib/openssl/buffering.rb	(revision 51465)
+++ ext/openssl/lib/openssl/buffering.rb	(revision 51466)
@@ -213,7 +213,7 @@ module OpenSSL::Buffering https://github.com/ruby/ruby/blob/trunk/ext/openssl/lib/openssl/buffering.rb#L213
     else
       size = idx ? idx+eol.size : nil
     end
-    if limit and limit >= 0
+    if size && limit && limit >= 0
       size = [size, limit].min
     end
     consume_rbuff(size)
Index: test/openssl/test_pair.rb
===================================================================
--- test/openssl/test_pair.rb	(revision 51465)
+++ test/openssl/test_pair.rb	(revision 51466)
@@ -110,6 +110,14 @@ module OpenSSL::TestPairM https://github.com/ruby/ruby/blob/trunk/test/openssl/test_pair.rb#L110
     }
   end
 
+  def test_gets_eof_limit
+    ssl_pair {|s1, s2|
+      s1.write("hello")
+      s1.close # trigger EOF
+      assert_match "hello", s2.gets("\n", 6), "[ruby-core:70149] [Bug #11140]"
+    }
+  end
+
   def test_readpartial
     ssl_pair {|s1, s2|
       s2.write "a\nbcd"

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

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