diff options
author | rhe <rhe@ruby-lang.org> | 2016-05-23 12:10:38 +0000 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2016-05-31 11:31:27 +0900 |
commit | e655faa38cdfbdd2da56c0b8db3a3fbb7094fa68 (patch) | |
tree | c385bdb0bda7d1bcf341e5d12f25ffa7d39e22ff /ext | |
parent | 63ac82669cea4603c414ca9c905cceee3d35bffb (diff) | |
download | ruby-openssl-e655faa38cdfbdd2da56c0b8db3a3fbb7094fa68.tar.gz |
openssl: Avoid reference to unset global variable in Init_openssl()
* ext/openssl/ossl.c (Init_openssl): Avoid reference to unset global
variable. ossl_raise() may be called before dOSSL is set. Since
global variables default to 0 and the default value of dOSSL set in
Init_openssl() is also Qfalse, there is no real issue but confusing.
Patch by Bertram Scharpf <software@bertram-scharpf.de>
[ruby-core:58264] [Bug #9101]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55135 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r-- | ext/openssl/ossl.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/ext/openssl/ossl.c b/ext/openssl/ossl.c index 1f62c57a..ad9c430d 100644 --- a/ext/openssl/ossl.c +++ b/ext/openssl/ossl.c @@ -1177,14 +1177,6 @@ Init_openssl(void) rb_global_variable(&eOSSLError); /* - * Verify callback Proc index for ext-data - */ - if ((ossl_store_ctx_ex_verify_cb_idx = X509_STORE_CTX_get_ex_new_index(0, (void *)"ossl_store_ctx_ex_verify_cb_idx", 0, 0, 0)) < 0) - ossl_raise(eOSSLError, "X509_STORE_CTX_get_ex_new_index"); - if ((ossl_store_ex_verify_cb_idx = X509_STORE_get_ex_new_index(0, (void *)"ossl_store_ex_verify_cb_idx", 0, 0, 0)) < 0) - ossl_raise(eOSSLError, "X509_STORE_get_ex_new_index"); - - /* * Init debug core */ dOSSL = Qfalse; @@ -1195,6 +1187,14 @@ Init_openssl(void) rb_define_module_function(mOSSL, "errors", ossl_get_errors, 0); /* + * Verify callback Proc index for ext-data + */ + if ((ossl_store_ctx_ex_verify_cb_idx = X509_STORE_CTX_get_ex_new_index(0, (void *)"ossl_store_ctx_ex_verify_cb_idx", 0, 0, 0)) < 0) + ossl_raise(eOSSLError, "X509_STORE_CTX_get_ex_new_index"); + if ((ossl_store_ex_verify_cb_idx = X509_STORE_get_ex_new_index(0, (void *)"ossl_store_ex_verify_cb_idx", 0, 0, 0)) < 0) + ossl_raise(eOSSLError, "X509_STORE_get_ex_new_index"); + + /* * Get ID of to_der */ ossl_s_to_der = rb_intern("to_der"); |