diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2022-09-08 15:37:15 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-08 15:37:15 +0900 |
commit | f54b5e568273a9e29782dfd86f0367721e6cb24a (patch) | |
tree | 66159c0e3e05d1bb93c1728efab3d426357d1ab5 /ext | |
parent | 9302d4863d9762c3196b724f605dcd5c7ca84a8b (diff) | |
parent | f6ee0fa4dee17f586eeaa0c1ca533c73c51ca9f7 (diff) | |
download | ruby-openssl-f54b5e568273a9e29782dfd86f0367721e6cb24a.tar.gz |
Merge pull request #541 from rhenium/ky/pkey-ec-export-segfault-regression
pkey/ec: check existence of public key component before exporting
Diffstat (limited to 'ext')
-rw-r--r-- | ext/openssl/ossl_pkey_ec.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/ext/openssl/ossl_pkey_ec.c b/ext/openssl/ossl_pkey_ec.c index dee21544..06d59c2a 100644 --- a/ext/openssl/ossl_pkey_ec.c +++ b/ext/openssl/ossl_pkey_ec.c @@ -414,6 +414,8 @@ ossl_ec_key_export(int argc, VALUE *argv, VALUE self) EC_KEY *ec; GetEC(self, ec); + if (EC_KEY_get0_public_key(ec) == NULL) + ossl_raise(eECError, "can't export - no public key set"); if (EC_KEY_get0_private_key(ec)) return ossl_pkey_export_traditional(argc, argv, self, 0); else @@ -432,6 +434,8 @@ ossl_ec_key_to_der(VALUE self) EC_KEY *ec; GetEC(self, ec); + if (EC_KEY_get0_public_key(ec) == NULL) + ossl_raise(eECError, "can't export - no public key set"); if (EC_KEY_get0_private_key(ec)) return ossl_pkey_export_traditional(0, NULL, self, 1); else |