mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-11 18:50:28 +09:00
Kex: fix coverity warning + edge case
This commit is contained in:
@@ -397,14 +397,18 @@ int set_client_kex(ssh_session session){
|
|||||||
if (methods & (1 << prefered_hostkeys[i])){
|
if (methods & (1 << prefered_hostkeys[i])){
|
||||||
if (verify_existing_algo(SSH_HOSTKEYS, ssh_key_type_to_char(prefered_hostkeys[i]))){
|
if (verify_existing_algo(SSH_HOSTKEYS, ssh_key_type_to_char(prefered_hostkeys[i]))){
|
||||||
if(needcoma)
|
if(needcoma)
|
||||||
strcat(methods_buffer,",");
|
strncat(methods_buffer,",",sizeof(methods_buffer)-strlen(methods_buffer)-1);
|
||||||
strcat(methods_buffer, ssh_key_type_to_char(prefered_hostkeys[i]));
|
strncat(methods_buffer, ssh_key_type_to_char(prefered_hostkeys[i]), sizeof(methods_buffer)-strlen(methods_buffer)-1);
|
||||||
needcoma = 1;
|
needcoma = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(strlen(methods_buffer) > 0){
|
||||||
SSH_LOG(SSH_LOG_DEBUG, "Changing host key method to \"%s\"", methods_buffer);
|
SSH_LOG(SSH_LOG_DEBUG, "Changing host key method to \"%s\"", methods_buffer);
|
||||||
session->opts.wanted_methods[SSH_HOSTKEYS] = strdup(methods_buffer);
|
session->opts.wanted_methods[SSH_HOSTKEYS] = strdup(methods_buffer);
|
||||||
|
} else {
|
||||||
|
SSH_LOG(SSH_LOG_DEBUG, "No supported kex method for existing key in known_hosts file");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user