1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2026-01-06 14:21:55 +03:00

dh: plug pubkey_blob leak in ssh_server_dh_process_init

Ensure to `SSH_STRING_FREE` the pubkey_blob local in
`ssh_server_dh_process_init`.  The leak can be seen with
valgrind and the pkd tests with:

    valgrind \
      --leak-check=full \
      --show-leak-kinds=definite \
      ./pkd_hello -i1 -t torture_pkd_openssh_rsa_rsa_diffie_hellman_group14_sha1

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Jon Simons
2019-01-29 20:17:20 -05:00
committed by Andreas Schneider
parent b44987a164
commit 3334443089

View File

@@ -690,7 +690,8 @@ int ssh_server_dh_process_init(ssh_session session, ssh_buffer packet)
pubkey_blob,
session->next_crypto->f,
sig_blob);
ssh_string_free(sig_blob);
SSH_STRING_FREE(sig_blob);
SSH_STRING_FREE(pubkey_blob);
if(rc != SSH_OK) {
ssh_set_error_oom(session);
ssh_buffer_reinit(session->out_buffer);
@@ -717,6 +718,8 @@ error:
if (!bignum_ctx_invalid(ctx)) {
bignum_ctx_free(ctx);
}
SSH_STRING_FREE(sig_blob);
SSH_STRING_FREE(pubkey_blob);
session->session_state = SSH_SESSION_STATE_ERROR;
ssh_dh_cleanup(session->next_crypto);