dh-gex: fix double-ssh_dh_init_common memory leak

Fix a memory leak whereby the x, y, and k bignum fields within
a session's next_crypto structure were being unintentionally
initialized twice.

The leak can be seen before the fix 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_group_exchange_sha256

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:06:12 -05:00
committed by Andreas Schneider
parent 886681a421
commit b44987a164

View File

@@ -552,12 +552,6 @@ static SSH_PACKET_CALLBACK(ssh_packet_server_dhgex_request)
goto error;
}
rc = ssh_dh_init_common(session);
if (rc != SSH_OK){
ssh_set_error_oom(session);
goto error;
}
/* Minimum group size, preferred group size, maximum group size */
rc = ssh_buffer_unpack(packet, "ddd", &pmin, &pn, &pmax);
if (rc != SSH_OK){