diff --git a/src/kex.c b/src/kex.c index f1a1b566..695929e2 100644 --- a/src/kex.c +++ b/src/kex.c @@ -368,7 +368,7 @@ SSH_PACKET_CALLBACK(ssh_packet_kexinit){ for (i = 0; i < KEX_METHODS_SIZE; i++) { str = buffer_get_ssh_string(packet); if (str == NULL) { - break; + goto error; } rc = buffer_add_ssh_string(session->in_hashbuf, str); @@ -443,6 +443,11 @@ SSH_PACKET_CALLBACK(ssh_packet_kexinit){ error: ssh_string_free(str); for (i = 0; i < SSH_KEX_METHODS; i++) { + if (server_kex) { + session->next_crypto->client_kex.methods[i] = NULL; + } else { /* client */ + session->next_crypto->server_kex.methods[i] = NULL; + } SAFE_FREE(strings[i]); }