ruby-changes:70364
From: Kazuki <ko1@a...>
Date: Tue, 21 Dec 2021 00:11:23 +0900 (JST)
Subject: [ruby-changes:70364] 02a58fbfd1 (master): [ruby/openssl] pkey: do not check NULL argument in ossl_pkey_new()
https://git.ruby-lang.org/ruby.git/commit/?id=02a58fbfd1 From 02a58fbfd1406acde30bb7ca4d019f2bd09bfacd Mon Sep 17 00:00:00 2001 From: Kazuki Yamaguchi <k@r...> Date: Mon, 12 Apr 2021 13:55:10 +0900 Subject: [ruby/openssl] pkey: do not check NULL argument in ossl_pkey_new() Passing NULL to ossl_pkey_new() makes no sense in the first place, and in fact it is ensured not to be NULL in all cases. https://github.com/ruby/openssl/commit/316cb2a41f --- ext/openssl/ossl_pkey.c | 6 +----- ext/openssl/ossl_pkey.h | 1 + 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/ext/openssl/ossl_pkey.c b/ext/openssl/ossl_pkey.c index b08168a5813..6fae01db739 100644 --- a/ext/openssl/ossl_pkey.c +++ b/ext/openssl/ossl_pkey.c @@ -39,12 +39,8 @@ pkey_new0(VALUE arg) https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_pkey.c#L39 { EVP_PKEY *pkey = (EVP_PKEY *)arg; VALUE klass, obj; - int type; - if (!pkey || (type = EVP_PKEY_base_id(pkey)) == EVP_PKEY_NONE) - ossl_raise(rb_eRuntimeError, "pkey is empty"); - - switch (type) { + switch (EVP_PKEY_base_id(pkey)) { #if !defined(OPENSSL_NO_RSA) case EVP_PKEY_RSA: klass = cRSA; break; #endif diff --git a/ext/openssl/ossl_pkey.h b/ext/openssl/ossl_pkey.h index 4beede22b55..f0476780fb8 100644 --- a/ext/openssl/ossl_pkey.h +++ b/ext/openssl/ossl_pkey.h @@ -35,6 +35,7 @@ extern const rb_data_type_t ossl_evp_pkey_type; https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_pkey.h#L35 } \ } while (0) +/* Takes ownership of the EVP_PKEY */ VALUE ossl_pkey_new(EVP_PKEY *); void ossl_pkey_check_public_key(const EVP_PKEY *); EVP_PKEY *ossl_pkey_read_generic(BIO *, VALUE); -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/