1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-11-30 13:01:23 +03:00

SSH-01-006: Add missing NULL check in server_set_kex()

Fixes T193

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
Andreas Schneider
2019-10-28 14:31:54 +01:00
parent 8aa2bbd0dc
commit 9ae81c5ceb

View File

@@ -168,13 +168,20 @@ int server_set_kex(ssh_session session)
for (i = 0; i < SSH_KEX_METHODS; i++) { for (i = 0; i < SSH_KEX_METHODS; i++) {
wanted = session->opts.wanted_methods[i]; wanted = session->opts.wanted_methods[i];
if (wanted == NULL) { if (wanted == NULL) {
if (ssh_fips_mode()) { if (ssh_fips_mode()) {
wanted = ssh_kex_get_fips_methods(i); wanted = ssh_kex_get_fips_methods(i);
} else { } else {
wanted = ssh_kex_get_default_methods(i); wanted = ssh_kex_get_default_methods(i);
} }
} }
if (wanted == NULL) {
for (j = 0; j < i; j++) {
SAFE_FREE(server->methods[j]);
}
return -1;
}
server->methods[i] = strdup(wanted); server->methods[i] = strdup(wanted);
if (server->methods[i] == NULL) { if (server->methods[i] == NULL) {
for (j = 0; j < i; j++) { for (j = 0; j < i; j++) {