diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2017-09-24 14:16:30 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-24 14:16:30 +0900 |
commit | 295dd1d4a5870821a4c792179a48efacd556cab9 (patch) | |
tree | 9302c082661070d8a9b09b2a6b30378d86dc59fc /test | |
parent | 45bec388132a156471be5fae9713bcc7ea65530b (diff) | |
parent | 6ff7844ea13ded27241fed9c641a20081b8ff402 (diff) | |
download | ruby-openssl-295dd1d4a5870821a4c792179a48efacd556cab9.tar.gz |
Merge pull request #153 from rhenium/ky/ssl-read-fix-leak-uninitialized
ssl: prevent SSLSocket#sysread* from leaking uninitialized data
Diffstat (limited to 'test')
-rw-r--r-- | test/test_pair.rb | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/test/test_pair.rb b/test/test_pair.rb index 7daa9288..ea5f0dcf 100644 --- a/test/test_pair.rb +++ b/test/test_pair.rb @@ -218,7 +218,7 @@ module OpenSSL::TestPairM assert_nothing_raised("[ruby-core:20298]") { ret = s2.read_nonblock(10) } assert_equal("def\n", ret) s1.close - sleep 0.1 + IO.select([s2]) assert_raise(EOFError) { s2.read_nonblock(10) } } end @@ -234,11 +234,35 @@ module OpenSSL::TestPairM assert_nothing_raised("[ruby-core:20298]") { ret = s2.read_nonblock(10, exception: false) } assert_equal("def\n", ret) s1.close - sleep 0.1 + IO.select([s2]) assert_equal(nil, s2.read_nonblock(10, exception: false)) } end + def test_read_with_outbuf + ssl_pair { |s1, s2| + s1.write("abc\n") + buf = "" + ret = s2.read(2, buf) + assert_same ret, buf + assert_equal "ab", ret + + buf = "garbage" + ret = s2.read(2, buf) + assert_same ret, buf + assert_equal "c\n", ret + + buf = "garbage" + assert_equal :wait_readable, s2.read_nonblock(100, buf, exception: false) + assert_equal "", buf + + s1.close + buf = "garbage" + assert_equal nil, s2.read(100, buf) + assert_equal "", buf + } + end + def test_write_nonblock ssl_pair {|s1, s2| assert_equal 3, s1.write_nonblock("foo") |