aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2016-11-15 17:51:16 +0900
committerKazuki Yamaguchi <k@rhe.jp>2016-11-16 00:12:21 +0900
commitc1dd6b096f5174e1d57584e603f58a0a76a9db43 (patch)
tree93b978d0724758f48ad479c380d58f794780935f
parent36bf7f403ebb6cefcaa1e7af9d8ec99e6b4bc1ed (diff)
downloadruby-openssl-c1dd6b096f5174e1d57584e603f58a0a76a9db43.tar.gz
engine: undef alloc function
This prevents users from allocating OpenSSL::Engine instance using OpenSSL::Engine.allocate. Undef'ing alloc function also allows us to remove explicit undef of OpenSSL::Engine.new and #initialize_copy.
-rw-r--r--ext/openssl/ossl_engine.c19
-rw-r--r--test/test_engine.rb7
2 files changed, 1 insertions, 25 deletions
diff --git a/ext/openssl/ossl_engine.c b/ext/openssl/ossl_engine.c
index f4863b36..e73bfb30 100644
--- a/ext/openssl/ossl_engine.c
+++ b/ext/openssl/ossl_engine.c
@@ -227,21 +227,6 @@ ossl_engine_s_by_id(VALUE klass, VALUE id)
return obj;
}
-static VALUE
-ossl_engine_s_alloc(VALUE klass)
-{
- ENGINE *e;
- VALUE obj;
-
- obj = NewEngine(klass);
- if (!(e = ENGINE_new())) {
- ossl_raise(eEngineError, NULL);
- }
- SetEngine(obj, e);
-
- return obj;
-}
-
/* Document-method: OpenSSL::Engine#id
*
* Get the id for this engine
@@ -537,13 +522,11 @@ Init_ossl_engine(void)
cEngine = rb_define_class_under(mOSSL, "Engine", rb_cObject);
eEngineError = rb_define_class_under(cEngine, "EngineError", eOSSLError);
- rb_define_alloc_func(cEngine, ossl_engine_s_alloc);
+ rb_undef_alloc_func(cEngine);
rb_define_singleton_method(cEngine, "load", ossl_engine_s_load, -1);
rb_define_singleton_method(cEngine, "cleanup", ossl_engine_s_cleanup, 0);
rb_define_singleton_method(cEngine, "engines", ossl_engine_s_engines, 0);
rb_define_singleton_method(cEngine, "by_id", ossl_engine_s_by_id, 1);
- rb_undef_method(CLASS_OF(cEngine), "new");
- rb_undef_method(cEngine, "initialize_copy");
rb_define_method(cEngine, "id", ossl_engine_get_id, 0);
rb_define_method(cEngine, "name", ossl_engine_get_name, 0);
diff --git a/test/test_engine.rb b/test/test_engine.rb
index 2d394cf7..75e45eb7 100644
--- a/test/test_engine.rb
+++ b/test/test_engine.rb
@@ -72,13 +72,6 @@ class OpenSSL::TestEngine < OpenSSL::TestCase
end;
end
- def test_dup
- with_openssl <<-'end;'
- engine = get_engine
- assert_raise(NoMethodError) { engine.dup }
- end;
- end
-
private
# this is required because OpenSSL::Engine methods change global state