Fix double free in EVP_PKEY_CTX_dup()
authorslontis <shane.lontis@oracle.com>
Thu, 2 Sep 2021 06:39:21 +0000 (16:39 +1000)
committerTomas Mraz <tomas@openssl.org>
Fri, 3 Sep 2021 10:34:47 +0000 (12:34 +0200)
commit9d924c4fd4d901d5e698f221afc4c9fc6761940f
tree4e119b22598909bb7f3aee86f942d57f2d2320f5
parent443cd5b08cd1e3b86d6a6c8894f65757355819e2
Fix double free in EVP_PKEY_CTX_dup()

If the internal operations dupctx() fails then a free is done (e.g. EVP_KEYEXCH_free()). If this is not set to NULL the EVP_PKEY_CTX_free() will do a double free.
This was found by testing kdf_dupctx() in kdf_exch.c (Note this always
fails since the internal KDF's do not have a dup method).

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16495)

(cherry picked from commit 85407b77543a2d4330dbb40f6b8520ea0894a716)
crypto/evp/pmeth_lib.c
test/evp_pkey_provided_test.c