openssl/crypto/ec
Nicola Tuveri 0c5d725ebf Fix segfault in RSA_free() (and DSA/DH/EC_KEY)
`RSA_free()` and friends are called in case of error from
`RSA_new_method(ENGINE *e)` (or the respective equivalent functions).

For the rest of the description I'll talk about `RSA_*`, but the same
applies for the equivalent `DSA_free()`, `DH_free()`, `EC_KEY_free()`.

If `RSA_new_method()` fails because the engine does not implement the
required method, when `RSA_free(RSA *r)` is called,
`r->meth == NULL` and a segfault happens while checking if
`r->meth->finish` is defined.

This commit fixes this issue by ensuring that `r->meth` is not NULL
before dereferencing it to check for `r->meth->finish`.

Fixes #7102 .

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/7121)
2018-09-05 15:22:35 +03:00
..
asm Add ec/asm/x25519-ppc64.pl module. 2018-07-26 14:01:49 +02:00
curve448 Fix some undefined behaviour in the Curve448 code (2nd attempt) 2018-08-03 12:02:14 +02:00
build.info Add ec/asm/x25519-ppc64.pl module. 2018-07-26 14:01:49 +02:00
curve25519.c ec/curve25519.c: reorganize for better accessibility. 2018-07-15 19:06:06 +02:00
ec2_oct.c Use the new non-curve type specific EC functions internally 2018-07-31 09:08:38 +01:00
ec2_smpl.c Use the new non-curve type specific EC functions internally 2018-07-31 09:08:38 +01:00
ec_ameth.c Check for failures, to avoid memory leak 2018-07-25 15:57:18 -04:00
ec_asn1.c Use the new non-curve type specific EC functions internally 2018-07-31 09:08:38 +01:00
ec_check.c Copyright consolidation 06/10 2016-05-17 14:51:04 -04:00
ec_curve.c Use the new non-curve type specific EC functions internally 2018-07-31 09:08:38 +01:00
ec_cvt.c Use the new non-curve type specific EC functions internally 2018-07-31 09:08:38 +01:00
ec_err.c Provide EC functions that are not curve type specific 2018-07-31 09:08:38 +01:00
ec_key.c Fix segfault in RSA_free() (and DSA/DH/EC_KEY) 2018-09-05 15:22:35 +03:00
ec_kmeth.c Fix const correctness of EC_KEY_METHOD_get_* 2017-07-23 11:34:11 +02:00
ec_lcl.h Use the new non-curve type specific EC functions internally 2018-07-31 09:08:38 +01:00
ec_lib.c [test] throw error from wrapper function instead of an EC_METHOD specific one 2018-09-03 20:25:41 +02:00
ec_mult.c EC2M Lopez-Dahab ladder: use it also for ECDSA verify 2018-07-16 10:17:40 +01:00
ec_oct.c Deprecate the EC curve type specific functions in 1.2.0 2018-07-31 09:08:50 +01:00
ec_pmeth.c ec/ec_pmeth.c: minor cleanups and readability fixes. 2018-06-25 16:42:43 +02:00
ec_print.c Update copyright year 2018-04-17 15:18:40 +02:00
ecdh_kdf.c check return values for EVP_Digest*() APIs 2016-07-15 14:09:05 +01:00
ecdh_ossl.c Use the new non-curve type specific EC functions internally 2018-07-31 09:08:38 +01:00
ecdsa_ossl.c Use the new non-curve type specific EC functions internally 2018-07-31 09:08:38 +01:00
ecdsa_sign.c Useless includes 2016-06-18 16:30:24 -04:00
ecdsa_vrf.c Useless includes 2016-06-18 16:30:24 -04:00
eck_prn.c Use the new non-curve type specific EC functions internally 2018-07-31 09:08:38 +01:00
ecp_mont.c EC GFp ladder 2018-07-26 19:41:16 +02:00
ecp_nist.c EC GFp ladder 2018-07-26 19:41:16 +02:00
ecp_nistp224.c Use the new non-curve type specific EC functions internally 2018-07-31 09:08:38 +01:00
ecp_nistp256.c Use the new non-curve type specific EC functions internally 2018-07-31 09:08:38 +01:00
ecp_nistp521.c Use the new non-curve type specific EC functions internally 2018-07-31 09:08:38 +01:00
ecp_nistputil.c Copyright consolidation 06/10 2016-05-17 14:51:04 -04:00
ecp_nistz256.c ec/ecp_nistz256.c: fix Coverity nit. 2018-07-25 15:45:18 +02:00
ecp_nistz256_table.c Copyright consolidation 05/10 2016-05-17 15:38:09 -04:00
ecp_oct.c Use the new non-curve type specific EC functions internally 2018-07-31 09:08:38 +01:00
ecp_smpl.c Replace GFp ladder implementation with ladd-2002-it-4 from EFD 2018-08-21 09:51:18 +01:00
ecx_meth.c Improve the usability of the ca app using EdDSA 2018-08-22 16:35:54 +01:00