diff options
author | rhe <rhe@ruby-lang.org> | 2016-05-21 07:25:00 +0000 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2016-05-31 11:31:27 +0900 |
commit | 63f74fb70f8059e08a69dfe0aa8216ef2d9dd0d3 (patch) | |
tree | 933292a460008c8c2f3dc67f13453bd28b377313 /lib | |
parent | fbb063354800b4b561a6b64fccddfcaf8a5011f4 (diff) | |
download | ruby-openssl-63f74fb70f8059e08a69dfe0aa8216ef2d9dd0d3.tar.gz |
openssl: fix possible SEGV on race between SSLSocket#stop and #connect
* ext/openssl/ossl_ssl.c (ossl_ssl_stop): Don't free the SSL struct
here. Since some methods such as SSLSocket#connect releases GVL,
there is a chance of use after free if we free the SSL from another
thread. SSLSocket#stop was documented as "prepares it for another
connection" so this is a slightly incompatible change. However when
this sentence was added (r30090, Add toplevel documentation for
OpenSSL, 2010-12-06), it didn't actually. The current behavior is
from r40304 (Correct shutdown behavior w.r.t GC., 2013-04-15).
[ruby-core:74978] [Bug #12292]
* ext/openssl/lib/openssl/ssl.rb (sysclose): Update doc.
* test/openssl/test_ssl.rb: Test this.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55100 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/openssl/ssl.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/openssl/ssl.rb b/lib/openssl/ssl.rb index 57519f2c..98937570 100644 --- a/lib/openssl/ssl.rb +++ b/lib/openssl/ssl.rb @@ -290,7 +290,10 @@ module OpenSSL # call-seq: # ssl.sysclose => nil # - # Shuts down the SSL connection and prepares it for another connection. + # Sends "close notify" to the peer and tries to shut down the SSL + # connection gracefully. + # + # If sync_close is set to +true+, the underlying IO is also closed. def sysclose return if closed? stop |