CVE-2020-1730: Fix a possible segfault when zeroing AES-CTR key

Fixes T213

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
(cherry picked from commit b36272eac1)
This commit is contained in:
Andreas Schneider
2020-02-11 11:52:33 +01:00
parent e510de0315
commit 958afb1c6a

View File

@@ -708,8 +708,12 @@ aes_ctr_encrypt(struct ssh_cipher_struct *cipher,
}
static void aes_ctr_cleanup(struct ssh_cipher_struct *cipher){
explicit_bzero(cipher->aes_key, sizeof(*cipher->aes_key));
SAFE_FREE(cipher->aes_key);
if (cipher != NULL) {
if (cipher->aes_key != NULL) {
explicit_bzero(cipher->aes_key, sizeof(*cipher->aes_key));
}
SAFE_FREE(cipher->aes_key);
}
}
#endif /* HAVE_OPENSSL_EVP_AES_CTR */