aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Simons <jon@jonsimons.org>2019-04-30 11:54:33 -0700
committerAndreas Schneider <asn@cryptomilk.org>2019-05-09 17:37:33 +0200
commitee42e3badba48083b5dd06bc3eb2111b46120723 (patch)
treea6b07648bd5a3eead990bad0fa809d29e93bc3d9
parentee82bab80166bc7ad8a109471d577389fd4f7a26 (diff)
downloadlibssh-ee42e3badba48083b5dd06bc3eb2111b46120723.tar.gz
libssh-ee42e3badba48083b5dd06bc3eb2111b46120723.tar.xz
libssh-ee42e3badba48083b5dd06bc3eb2111b46120723.zip
dh: fix libcrypto dh_ctx leak in ssh_dh_cleanup
Ensure to free the `dh_ctx` member in `ssh_dh_cleanup` to match the allocation in `ssh_dh_init_common`. The before-and-after of this change can be observed with the pkd tests and valgrind: valgrind --leak-check=full \ ./pkd_hello -i1 -t torture_pkd_openssh_dsa_rsa_diffie_hellman_group16_sha512 Signed-off-by: Jon Simons <jon@jonsimons.org> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
-rw-r--r--src/dh_crypto.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/dh_crypto.c b/src/dh_crypto.c
index bcf0c837..20d38383 100644
--- a/src/dh_crypto.c
+++ b/src/dh_crypto.c
@@ -180,6 +180,7 @@ void ssh_dh_cleanup(struct ssh_crypto_struct *crypto)
if (crypto->dh_ctx != NULL) {
DH_free(crypto->dh_ctx->keypair[0]);
DH_free(crypto->dh_ctx->keypair[1]);
+ free(crypto->dh_ctx);
crypto->dh_ctx = NULL;
}
}