From: Ippei Obayashi Date: 2010-11-15T00:51:40+09:00 Subject: [ruby-dev:42573] [Ruby 1.9-Bug#4055][Open] segfault in OpenSSL::SSLSocket#cert Bug #4055: segfault in OpenSSL::SSLSocket#cert http://redmine.ruby-lang.org/issues/show/4055 起票者: Ippei Obayashi ステータス: Open, 優先度: Normal カテゴリ: ext, Target version: 1.9.2 ruby -v: ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-linux] 以下のようにすると Segmentation fault を起こします。 ruby-1.9.2-p0 -e 'require "openssl"; OpenSSL::SSL::SSLSocket.new(STDIN).cert' 以下のパッチで直ると思います。 --- a/ext/openssl/ossl_ssl.c +++ b/ext/openssl/ossl_ssl.c @@ -1337,7 +1337,7 @@ ossl_ssl_get_cert(VALUE self) X509 *cert = NULL; Data_Get_Struct(self, SSL, ssl); - if (ssl) { + if (!ssl) { rb_warning("SSL session is not started yet."); return Qnil; } バックトレースは以下の通り。 ---- -e:1: [BUG] Segmentation fault ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-linux] -- control frame ---------- c:0004 p:---- s:0009 b:0009 l:000008 d:000008 CFUNC :cert c:0003 p:0044 s:0006 b:0006 l:0017f8 d:000118 EVAL -e:1 c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH c:0001 p:0000 s:0002 b:0002 l:0017f8 d:0017f8 TOP --------------------------- -- Ruby level backtrace information ---------------------------------------- -e:1:in `
' -e:1:in `cert' -- C level backtrace information ------------------------------------------- /home/ohai/opt/ruby-1.9.2-p0/lib/libruby.so.1.9(rb_vm_bugreport+0x5f) [0x7fc3ef8ddc1f] /home/ohai/opt/ruby-1.9.2-p0/lib/libruby.so.1.9 [0x7fc3ef7bb0dc] /home/ohai/opt/ruby-1.9.2-p0/lib/libruby.so.1.9(rb_bug+0xb3) [0x7fc3ef7bb253] /home/ohai/opt/ruby-1.9.2-p0/lib/libruby.so.1.9 [0x7fc3ef86ca9c] /lib/libpthread.so.0 [0x7fc3ef548a80] /usr/lib/libssl.so.0.9.8(SSL_get_certificate+0) [0x7fc3e9ec57f0] /home/ohai/opt/ruby-1.9.2-p0/lib/ruby/1.9.1/x86_64-linux/openssl.so [0x7fc3ea10fc77] /home/ohai/opt/ruby-1.9.2-p0/lib/libruby.so.1.9 [0x7fc3ef8d7f1f] /home/ohai/opt/ruby-1.9.2-p0/lib/libruby.so.1.9 [0x7fc3ef8cbf09] /home/ohai/opt/ruby-1.9.2-p0/lib/libruby.so.1.9 [0x7fc3ef8d2103] /home/ohai/opt/ruby-1.9.2-p0/lib/libruby.so.1.9(rb_iseq_eval_main+0x27c) [0x7fc3ef8d247c] /home/ohai/opt/ruby-1.9.2-p0/lib/libruby.so.1.9 [0x7fc3ef7bf29b] /home/ohai/opt/ruby-1.9.2-p0/lib/libruby.so.1.9(ruby_exec_node+0x19) [0x7fc3ef7bf2c9] /home/ohai/opt/ruby-1.9.2-p0/lib/libruby.so.1.9(ruby_run_node+0x1e) [0x7fc3ef7c0e0e] ruby-1.9.2-p0(main+0x4f) [0x40099f] /lib/libc.so.6(__libc_start_main+0xe6) [0x7fc3ee93d1a6] ruby-1.9.2-p0 [0x400889] [NOTE] You may have encountered a bug in the Ruby interpreter or extension libraries. Bug reports are welcome. For details: http://www.ruby-lang.org/bugreport.html ---------------------------------------- http://redmine.ruby-lang.org