dumping ground for random patches and texts
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: spew@80x24.org
Subject: [PATCH] openssl/buffering: fix gets on EOF with limit
Date: Sat,  1 Aug 2015 21:57:03 +0000	[thread overview]
Message-ID: <1438466223-8074-1-git-send-email-e@80x24.org> (raw)

* 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@safe-t.com> for the bug report
  and testing.  [ruby-core:70149] [Bug #11400]
---
 ext/openssl/lib/openssl/buffering.rb | 2 +-
 test/openssl/test_pair.rb            | 8 ++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/ext/openssl/lib/openssl/buffering.rb b/ext/openssl/lib/openssl/buffering.rb
index 099e960..63444cc 100644
--- a/ext/openssl/lib/openssl/buffering.rb
+++ b/ext/openssl/lib/openssl/buffering.rb
@@ -213,7 +213,7 @@ module OpenSSL::Buffering
     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)
diff --git a/test/openssl/test_pair.rb b/test/openssl/test_pair.rb
index cd5d5d8..c742eb6 100644
--- a/test/openssl/test_pair.rb
+++ b/test/openssl/test_pair.rb
@@ -110,6 +110,14 @@ module OpenSSL::TestPairM
     }
   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"
-- 
EW


                 reply	other threads:[~2015-08-01 21:57 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1438466223-8074-1-git-send-email-e@80x24.org \
    --to=e@80x24.org \
    --cc=spew@80x24.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).