From ee42e3badba48083b5dd06bc3eb2111b46120723 Mon Sep 17 00:00:00 2001 From: Jon Simons Date: Tue, 30 Apr 2019 11:54:33 -0700 Subject: [PATCH] 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 Reviewed-by: Andreas Schneider --- src/dh_crypto.c | 1 + 1 file changed, 1 insertion(+) 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; } }