Fix a crash in EVP_CIPHER_CTX_cleanup due to cipher_data may be NULL
authorBernd Edlinger <bernd.edlinger@hotmail.de>
Mon, 6 Feb 2017 12:37:42 +0000 (13:37 +0100)
committerMatt Caswell <matt@openssl.org>
Tue, 7 Feb 2017 09:16:14 +0000 (09:16 +0000)
commitf8b21b98e96096eac702b814900100be922c6534
treed077aebdfe11440386055942522f0d13c222d394
parent85342b7d4ffa26fb0316c9cb5574a0d0bedc8a1e
Fix a crash in EVP_CIPHER_CTX_cleanup due to cipher_data may be NULL
or EVP_CTRL_INIT/EVP_CTRL_COPY was not called or failed.
If that happens in EVP_CipherInit_ex/EVP_CIPHER_CTX_copy set cipher = NULL,
aes_gcm_cleanup should check that gctx != NULL before calling OPENSSL_cleanse.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/2562)
(cherry picked from commit 273a0218e65f1737cdbb0ef65a5ddebd601e6bef)
crypto/evp/e_aes.c
crypto/evp/evp_enc.c