summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTilo Eckert <tilo.eckert@flam.de>2018-10-12 15:15:00 +0200
committerAndreas Schneider <asn@cryptomilk.org>2018-10-13 22:08:36 +0200
commit45058285fca549876449afef2c32833b24817e77 (patch)
treee011251a99d409c5e2355480b0d8b4a41cf9d4a9
parent42bd7cdf6c6e50786155c904821fc62d6d8e5acb (diff)
downloadlibssh-45058285fca549876449afef2c32833b24817e77.tar.gz
libssh-45058285fca549876449afef2c32833b24817e77.tar.xz
libssh-45058285fca549876449afef2c32833b24817e77.zip
knownhosts: Fix invalid read of known_hosts token
Fixes invalid read introduced by commit 21962d. Accessing tokens[4] for a known_hosts line of three tokens led to randomly rejected host keys. This commit completely removes the check because the optional comments field may contain whitespace. Signed-off-by: Tilo Eckert <tilo.eckert@flam.de>
-rw-r--r--src/known_hosts.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/src/known_hosts.c b/src/known_hosts.c
index f52f74b3..407e1de5 100644
--- a/src/known_hosts.c
+++ b/src/known_hosts.c
@@ -131,17 +131,13 @@ static char **ssh_get_knownhost_line(FILE **file, const char *filename,
return NULL;
}
- if(!tokens[0] || !tokens[1] || !tokens[2]) {
+ if(tokens[0] == NULL || tokens[1] == NULL || tokens[2] == NULL) {
/* it should have at least 3 tokens */
tokens_free(tokens);
continue;
}
*found_type = tokens[1];
- if (tokens[3] || tokens[4]) {
- tokens_free(tokens);
- continue;
- }
return tokens;
}