aboutsummaryrefslogtreecommitdiff
path: root/libssh/keyfiles.c
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2010-05-01 00:40:10 +0200
committerAris Adamantiadis <aris@0xbadc0de.be>2010-05-01 00:40:10 +0200
commit22be109956d0fe66e09bf9b13d1d2a37f7678cba (patch)
tree9364d0036cad69880094367e6f9b632445cd0782 /libssh/keyfiles.c
parent4bb790fb5de3d64097cae77955a96260d11ae3db (diff)
downloadlibssh-22be109956d0fe66e09bf9b13d1d2a37f7678cba.tar.gz
libssh-22be109956d0fe66e09bf9b13d1d2a37f7678cba.tar.xz
libssh-22be109956d0fe66e09bf9b13d1d2a37f7678cba.zip
First implementation of known_hosts with port read
Diffstat (limited to 'libssh/keyfiles.c')
-rw-r--r--libssh/keyfiles.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/libssh/keyfiles.c b/libssh/keyfiles.c
index a5aae8c..63b6321 100644
--- a/libssh/keyfiles.c
+++ b/libssh/keyfiles.c
@@ -1594,6 +1594,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;
@@ -1617,8 +1618,11 @@ int ssh_is_server_known(ssh_session session) {
}
host = ssh_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;
}
@@ -1632,10 +1636,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) {
@@ -1671,6 +1677,7 @@ int ssh_is_server_known(ssh_session session) {
}
SAFE_FREE(host);
+ SAFE_FREE(hostport);
if (file != NULL) {
fclose(file);
}