aboutsummaryrefslogtreecommitdiff
path: root/src/wrapper.c
diff options
context:
space:
mode:
authordebevv <valerio@sonicpengu.in>2017-06-06 09:28:58 +0200
committerAndreas Schneider <asn@cryptomilk.org>2017-06-06 10:21:55 +0200
commit48e7b098f86207f8596651b5ba8242a3b834a868 (patch)
treeed6dac9f8deb81bd2f041c6375aad5f23a4aaa7e /src/wrapper.c
parent5333be5988c3789e7011598995f4df90d50d84d0 (diff)
downloadlibssh-48e7b098f86207f8596651b5ba8242a3b834a868.tar.gz
libssh-48e7b098f86207f8596651b5ba8242a3b834a868.tar.xz
libssh-48e7b098f86207f8596651b5ba8242a3b834a868.zip
wrapper: Fix possible crash in ssh_handle_key_exchange()
If ssh_handle_key_exchange() fails, when ssh_free() is called cipher->ctx is NULL. Signed-off-by: debevv <valerio@sonicpengu.in>
Diffstat (limited to 'src/wrapper.c')
-rw-r--r--src/wrapper.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/wrapper.c b/src/wrapper.c
index af166dae..877b807b 100644
--- a/src/wrapper.c
+++ b/src/wrapper.c
@@ -120,12 +120,14 @@ void ssh_cipher_clear(struct ssh_cipher_struct *cipher){
SAFE_FREE(cipher->key);
}
#endif
- if (cipher->cleanup != NULL){
- cipher->cleanup(cipher);
- }
+ if (cipher->ctx != NULL) {
+ if (cipher->cleanup != NULL) {
+ cipher->cleanup(cipher);
+ }
#ifdef HAVE_LIBCRYPTO
- EVP_CIPHER_CTX_free(cipher->ctx);
+ EVP_CIPHER_CTX_free(cipher->ctx);
#endif
+ }
}
static void cipher_free(struct ssh_cipher_struct *cipher) {