openssl/crypto/dh
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
..
build.info
dh192.pem
dh512.pem
dh1024.pem
dh2048.pem
dh4096.pem
dh_ameth.c
dh_asn1.c
dh_check.c
dh_depr.c
dh_err.c Set error code on alloc failures 2018-04-03 11:31:16 -04:00
dh_gen.c
dh_kdf.c
dh_key.c Update copyright year 2018-06-20 15:29:23 +01:00
dh_lib.c Fix segfault in RSA_free() (and DSA/DH/EC_KEY) 2018-09-05 15:22:35 +03:00
dh_locl.h
dh_meth.c Update copyright year 2018-04-03 13:57:12 +01:00
dh_pmeth.c Update copyright year 2018-04-17 15:18:40 +02:00
dh_prn.c
dh_rfc5114.c
dh_rfc7919.c