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

ruby-changes:20556

From: emboss <ko1@a...>
Date: Fri, 22 Jul 2011 09:13:17 +0900 (JST)
Subject: [ruby-changes:20556] emboss:r32604 (trunk): * ext/openssl/ossl_engine.c: Avoid double free of ENGINE reference.

emboss	2011-07-22 09:13:07 +0900 (Fri, 22 Jul 2011)

  New Revision: 32604

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

  Log:
    * ext/openssl/ossl_engine.c: Avoid double free of ENGINE reference.
    * test/openssl/test_engine.rb: Add a test for it.
      Thanks to Ippei Obayashi for providing the patch.
      [ Ruby 1.9 - Bug #5062 ] [ruby-dev:44173]

  Added files:
    trunk/test/openssl/test_engine.rb
  Modified files:
    trunk/ChangeLog
    trunk/ext/openssl/ossl_engine.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 32603)
+++ ChangeLog	(revision 32604)
@@ -1,3 +1,10 @@
+Fri Jul 22 09:09:43 2011  Martin Bosslet  <Martin.Bosslet@g...>
+
+	* ext/openssl/ossl_engine.c: Avoid double free of ENGINE reference.
+	* test/openssl/test_engine.rb: Add a test for it.
+	  Thanks to Ippei Obayashi for providing the patch.
+	  [ Ruby 1.9 - Bug #5062 ] [ruby-dev:44173]
+
 Fri Jul 22 06:37:13 2011  Marc-Andre Lafortune  <ruby-core@m...>
 
 	* lib/csv.rb: Do not modify CSV.generate's argument [ruby-core:38356]
Index: ext/openssl/ossl_engine.c
===================================================================
--- ext/openssl/ossl_engine.c	(revision 32603)
+++ ext/openssl/ossl_engine.c	(revision 32604)
@@ -115,7 +115,11 @@
 
     ary = rb_ary_new();
     for(e = ENGINE_get_first(); e; e = ENGINE_get_next(e)){
-        WrapEngine(klass, obj, e);
+	/* Need a ref count of two here because of ENGINE_free being
+	 * called internally by OpenSSL when moving to the next ENGINE
+	 * and by us when releasing the ENGINE reference */
+	ENGINE_up_ref(e); 
+	WrapEngine(klass, obj, e);
         rb_ary_push(ary, obj);
     }
 
Index: test/openssl/test_engine.rb
===================================================================
--- test/openssl/test_engine.rb	(revision 0)
+++ test/openssl/test_engine.rb	(revision 32604)
@@ -0,0 +1,15 @@
+require_relative 'utils'
+
+if defined?(OpenSSL)
+
+class OpenSSL::TestEngine < Test::Unit::TestCase
+
+  def test_engines_free # [ruby-dev:44173]
+    OpenSSL::Engine.load
+    OpenSSL::Engine.engines
+    OpenSSL::Engine.engines
+  end
+
+end
+
+end

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

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