diff options
| author | Aris Adamantiadis <aris@0xbadc0de.be> | 2010-05-07 12:55:33 +0200 |
|---|---|---|
| committer | Aris Adamantiadis <aris@0xbadc0de.be> | 2010-05-07 12:55:33 +0200 |
| commit | e9d6b15926214706bdc46ea1eccfab812956df1e (patch) | |
| tree | 7d4a45cf94698990d88a6c4b7d499b7ee8ba6a38 /libssh/keyfiles.c | |
| parent | 6885d32c05d517b32c949e17318878b1e143a83d (diff) | |
First implementation of known_hosts with port read
Conflicts:
include/libssh/misc.h
libssh/keyfiles.c
libssh/misc.c
Diffstat (limited to 'libssh/keyfiles.c')
| -rw-r--r-- | libssh/keyfiles.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/libssh/keyfiles.c b/libssh/keyfiles.c index a25af893..49741f3a 100644 --- a/libssh/keyfiles.c +++ b/libssh/keyfiles.c @@ -1570,6 +1570,7 @@ int ssh_is_server_known(ssh_session session) { FILE *file = NULL; char **tokens; char *host; + char *hostport; const char *type; int match; int ret = SSH_SERVER_NOT_KNOWN; @@ -1593,8 +1594,11 @@ int ssh_is_server_known(ssh_session session) { } host = lowercase(session->host); - if (host == NULL) { - ssh_set_error(session, SSH_FATAL, "Not enough space!"); + hostport = ssh_hostport(host,session->port); + if (host == NULL || hostport == NULL) { + ssh_set_error_oom(session); + SAFE_FREE(host); + SAFE_FREE(hostport); leave_function(); return SSH_SERVER_ERROR; } @@ -1608,10 +1612,12 @@ int ssh_is_server_known(ssh_session session) { break; } match = match_hashed_host(session, host, tokens[0]); + if (match == 0){ + match = match_hostname(hostport, tokens[0], strlen(tokens[0])); + } if (match == 0) { match = match_hostname(host, tokens[0], strlen(tokens[0])); } - if (match) { /* We got a match. Now check the key type */ if (strcmp(session->current_crypto->server_pubkey_type, type) != 0) { @@ -1642,6 +1648,7 @@ int ssh_is_server_known(ssh_session session) { } while (1); SAFE_FREE(host); + SAFE_FREE(hostport); if (file != NULL) { fclose(file); } |
