diff options
| author | Aris Adamantiadis <aris@0xbadc0de.be> | 2014-02-02 20:50:36 +0100 |
|---|---|---|
| committer | Aris Adamantiadis <aris@0xbadc0de.be> | 2014-02-02 20:50:36 +0100 |
| commit | 1e37430dbeb6db8bafc5c5382861b99ac192fa75 (patch) | |
| tree | b24efdac6e89107c2215213883172290d9f0b6dc /src | |
| parent | 671f1979a6d913938f5ced00779bf99db71f8df5 (diff) | |
| download | libssh-1e37430dbeb6db8bafc5c5382861b99ac192fa75.tar.gz libssh-1e37430dbeb6db8bafc5c5382861b99ac192fa75.tar.xz libssh-1e37430dbeb6db8bafc5c5382861b99ac192fa75.zip | |
Kex: fix coverity warning + edge case
Diffstat (limited to 'src')
| -rw-r--r-- | src/kex.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -397,14 +397,18 @@ int set_client_kex(ssh_session session){ if (methods & (1 << prefered_hostkeys[i])){ if (verify_existing_algo(SSH_HOSTKEYS, ssh_key_type_to_char(prefered_hostkeys[i]))){ if(needcoma) - strcat(methods_buffer,","); - strcat(methods_buffer, ssh_key_type_to_char(prefered_hostkeys[i])); + strncat(methods_buffer,",",sizeof(methods_buffer)-strlen(methods_buffer)-1); + strncat(methods_buffer, ssh_key_type_to_char(prefered_hostkeys[i]), sizeof(methods_buffer)-strlen(methods_buffer)-1); needcoma = 1; } } } - SSH_LOG(SSH_LOG_DEBUG, "Changing host key method to \"%s\"", methods_buffer); - session->opts.wanted_methods[SSH_HOSTKEYS] = strdup(methods_buffer); + if(strlen(methods_buffer) > 0){ + SSH_LOG(SSH_LOG_DEBUG, "Changing host key method to \"%s\"", 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"); + } } } |
