diff options
author | Samuel Williams <samuel.williams@oriontransfer.co.nz> | 2019-11-27 11:26:41 +0900 |
---|---|---|
committer | Samuel Williams <samuel.williams@oriontransfer.co.nz> | 2019-11-27 11:26:41 +0900 |
commit | b4e96fc4abc3bb3318bc1aa48b4413da4e932bb4 (patch) | |
tree | 107b364967f4ee69f5bcfccd3bf40521173f8ae2 /ext | |
parent | f48885c9400c272fa2647c47a891a515b97cda59 (diff) | |
download | ruby-openssl-b4e96fc4abc3bb3318bc1aa48b4413da4e932bb4.tar.gz |
Pull relevant changes from `ruby/ext/openssl`.
Diff was generated:
git diff --output openssl.patch 93bc10272734cbbb9197470ca629cc4ea019f6f0 ext/openssl/*.c ext/openssl/*.h ext/openssl/**/*.rb
Appled using `patch -p1 < openssl.patch`.
Diffstat (limited to 'ext')
-rw-r--r-- | ext/openssl/ossl.c | 4 | ||||
-rw-r--r-- | ext/openssl/ossl.h | 3 | ||||
-rw-r--r-- | ext/openssl/ossl_asn1.c | 2 | ||||
-rw-r--r-- | ext/openssl/ossl_bn.c | 7 | ||||
-rw-r--r-- | ext/openssl/ossl_ssl.c | 22 |
5 files changed, 25 insertions, 13 deletions
diff --git a/ext/openssl/ossl.c b/ext/openssl/ossl.c index bdf6053d..c8a2cef7 100644 --- a/ext/openssl/ossl.c +++ b/ext/openssl/ossl.c @@ -338,7 +338,7 @@ ossl_clear_error(void) * implementation. */ VALUE -ossl_get_errors(void) +ossl_get_errors(VALUE _) { VALUE ary; long e; @@ -398,7 +398,7 @@ ossl_debug_set(VALUE self, VALUE val) } /* - * call-seq + * call-seq: * OpenSSL.fips_mode -> true | false */ static VALUE diff --git a/ext/openssl/ossl.h b/ext/openssl/ossl.h index 2f76bdc8..4f5441c6 100644 --- a/ext/openssl/ossl.h +++ b/ext/openssl/ossl.h @@ -13,8 +13,8 @@ #include RUBY_EXTCONF_H #include <assert.h> -#include <errno.h> #include <ruby.h> +#include <errno.h> #include <ruby/io.h> #include <ruby/thread.h> #include <openssl/opensslv.h> @@ -27,7 +27,6 @@ #include <openssl/hmac.h> #include <openssl/rand.h> #include <openssl/conf.h> -#include <openssl/conf_api.h> #ifndef OPENSSL_NO_TS #include <openssl/ts.h> #endif diff --git a/ext/openssl/ossl_asn1.c b/ext/openssl/ossl_asn1.c index e23c4374..9eb1826f 100644 --- a/ext/openssl/ossl_asn1.c +++ b/ext/openssl/ossl_asn1.c @@ -1849,7 +1849,7 @@ do{\ rb_define_method(cASN1EndOfContent, "to_der", ossl_asn1eoc_to_der, 0); class_tag_map = rb_hash_new(); - rb_global_variable(&class_tag_map); + rb_gc_register_mark_object(class_tag_map); rb_hash_aset(class_tag_map, cASN1EndOfContent, INT2NUM(V_ASN1_EOC)); rb_hash_aset(class_tag_map, cASN1Boolean, INT2NUM(V_ASN1_BOOLEAN)); rb_hash_aset(class_tag_map, cASN1Integer, INT2NUM(V_ASN1_INTEGER)); diff --git a/ext/openssl/ossl_bn.c b/ext/openssl/ossl_bn.c index 0f9a6d3a..6493e051 100644 --- a/ext/openssl/ossl_bn.c +++ b/ext/openssl/ossl_bn.c @@ -186,6 +186,7 @@ ossl_bn_initialize(int argc, VALUE *argv, VALUE self) BIGNUM *bn; VALUE str, bs; int base = 10; + char *ptr; if (rb_scan_args(argc, argv, "11", &str, &bs) == 2) { base = NUM2INT(bs); @@ -216,12 +217,14 @@ ossl_bn_initialize(int argc, VALUE *argv, VALUE self) GetBN(self, bn); switch (base) { case 0: - if (!BN_mpi2bn((unsigned char *)StringValuePtr(str), RSTRING_LENINT(str), bn)) { + ptr = StringValuePtr(str); + if (!BN_mpi2bn((unsigned char *)ptr, RSTRING_LENINT(str), bn)) { ossl_raise(eBNError, NULL); } break; case 2: - if (!BN_bin2bn((unsigned char *)StringValuePtr(str), RSTRING_LENINT(str), bn)) { + ptr = StringValuePtr(str); + if (!BN_bin2bn((unsigned char *)ptr, RSTRING_LENINT(str), bn)) { ossl_raise(eBNError, NULL); } break; diff --git a/ext/openssl/ossl_ssl.c b/ext/openssl/ossl_ssl.c index f709b655..83df2478 100644 --- a/ext/openssl/ossl_ssl.c +++ b/ext/openssl/ossl_ssl.c @@ -380,7 +380,7 @@ ossl_call_session_get_cb(VALUE ary) } static SSL_SESSION * -#if OPENSSL_VERSION_NUMBER >= 0x10100000 && !defined(LIBRESSL_VERSION_NUMBER) +#if (!defined(LIBRESSL_VERSION_NUMBER) ? OPENSSL_VERSION_NUMBER >= 0x10100000 : LIBRESSL_VERSION_NUMBER >= 0x2080000f) ossl_sslctx_session_get_cb(SSL *ssl, const unsigned char *buf, int len, int *copy) #else ossl_sslctx_session_get_cb(SSL *ssl, unsigned char *buf, int len, int *copy) @@ -592,7 +592,7 @@ ssl_renegotiation_cb(const SSL *ssl) #if !defined(OPENSSL_NO_NEXTPROTONEG) || \ defined(HAVE_SSL_CTX_SET_ALPN_SELECT_CB) static VALUE -ssl_npn_encode_protocol_i(VALUE cur, VALUE encoded) +ssl_npn_encode_protocol_i(RB_BLOCK_CALL_FUNC_ARGLIST(cur, encoded)) { int len = RSTRING_LENINT(cur); char len_byte; @@ -1885,6 +1885,7 @@ ossl_ssl_read_internal(int argc, VALUE *argv, VALUE self, int nonblock) rb_eof_error(); } } + /* fall through */ default: ossl_raise(eSSLError, "SSL_read"); } @@ -1894,8 +1895,13 @@ ossl_ssl_read_internal(int argc, VALUE *argv, VALUE self, int nonblock) ID meth = nonblock ? rb_intern("read_nonblock") : rb_intern("sysread"); rb_warning("SSL session is not started yet."); - if (nonblock) - return rb_funcall(io, meth, 3, len, str, opts); + if (nonblock) { + VALUE argv[3]; + argv[0] = len; + argv[1] = str; + argv[2] = opts; + return rb_funcallv_kw(io, meth, 3, argv, RB_PASS_KEYWORDS); + } else return rb_funcall(io, meth, 2, len, str); } @@ -1985,8 +1991,12 @@ ossl_ssl_write_internal(VALUE self, VALUE str, VALUE opts) rb_intern("write_nonblock") : rb_intern("syswrite"); rb_warning("SSL session is not started yet."); - if (nonblock) - return rb_funcall(io, meth, 2, str, opts); + if (nonblock) { + VALUE argv[2]; + argv[0] = str; + argv[1] = opts; + return rb_funcallv_kw(io, meth, 2, argv, RB_PASS_KEYWORDS); + } else return rb_funcall(io, meth, 1, str); } |