aboutsummaryrefslogtreecommitdiff
path: root/src/libcrypto.c
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2020-02-11 11:52:33 +0100
committerAndreas Schneider <asn@cryptomilk.org>2020-04-09 09:28:03 +0200
commitb36272eac1b36982598c10de7af0a501582de07a (patch)
treeffd3206c86a403bf1fcd3c61f65f61d7f489e22b /src/libcrypto.c
parentcd15043656280e92714c139d820ef271d00876a4 (diff)
downloadlibssh-b36272eac1b36982598c10de7af0a501582de07a.tar.gz
libssh-b36272eac1b36982598c10de7af0a501582de07a.tar.xz
libssh-b36272eac1b36982598c10de7af0a501582de07a.zip
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>
Diffstat (limited to 'src/libcrypto.c')
-rw-r--r--src/libcrypto.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/libcrypto.c b/src/libcrypto.c
index b3792264..e9f519ec 100644
--- a/src/libcrypto.c
+++ b/src/libcrypto.c
@@ -713,8 +713,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 */