diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2022-09-02 23:05:28 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2022-09-02 23:20:15 +0900 |
commit | f6ee0fa4dee17f586eeaa0c1ca533c73c51ca9f7 (patch) | |
tree | f07d6ed5a7943e5b3b8d9efad13d4d490590ec94 /test | |
parent | bff4080091f1e468418b0a8625174f234922210c (diff) | |
download | ruby-openssl-f6ee0fa4dee17f586eeaa0c1ca533c73c51ca9f7.tar.gz |
pkey/ec: check existence of public key component before exportingky/pkey-ec-export-segfault-regression
i2d_PUBKEY_bio() against an EC_KEY without the public key component
trggers a null dereference.
This is a regression introduced by commit 56f0d34d63fb ("pkey:
refactor #export/#to_pem and #to_der", 2017-06-14).
Fixes https://github.com/ruby/openssl/pull/527#issuecomment-1220504524
Fixes https://github.com/ruby/openssl/issues/369#issuecomment-1221554057
Diffstat (limited to 'test')
-rw-r--r-- | test/openssl/test_pkey_ec.rb | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/test/openssl/test_pkey_ec.rb b/test/openssl/test_pkey_ec.rb index ffe5a94e..ba175861 100644 --- a/test/openssl/test_pkey_ec.rb +++ b/test/openssl/test_pkey_ec.rb @@ -61,8 +61,10 @@ class OpenSSL::TestEC < OpenSSL::PKeyTestCase def test_generate_key ec = OpenSSL::PKey::EC.new("prime256v1") assert_equal false, ec.private? + assert_raise(OpenSSL::PKey::ECError) { ec.to_der } ec.generate_key! assert_equal true, ec.private? + assert_nothing_raised { ec.to_der } end if !openssl?(3, 0, 0) def test_marshal |