summaryrefslogtreecommitdiffstats
path: root/libssh/keyfiles.c
diff options
context:
space:
mode:
authorAndreas Schneider <mail@cynapses.org>2009-04-01 10:49:27 +0000
committerAndreas Schneider <mail@cynapses.org>2009-04-01 10:49:27 +0000
commit79e9eb53d44d777f2aa094e643cc3ae796e7d4f4 (patch)
tree6c7668fbaac5321e871112ed0078c8307a1be92a /libssh/keyfiles.c
parent10afd9818cdf1fda8b19bae69dd2c8973dbbf606 (diff)
downloadlibssh-79e9eb53d44d777f2aa094e643cc3ae796e7d4f4.tar.gz
libssh-79e9eb53d44d777f2aa094e643cc3ae796e7d4f4.tar.xz
libssh-79e9eb53d44d777f2aa094e643cc3ae796e7d4f4.zip
Add memory error checking to key exchange functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@317 7dcaeef0-15fb-0310-b436-a5af3365683c
Diffstat (limited to 'libssh/keyfiles.c')
-rw-r--r--libssh/keyfiles.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/libssh/keyfiles.c b/libssh/keyfiles.c
index a4cec4e6..c45d9abd 100644
--- a/libssh/keyfiles.c
+++ b/libssh/keyfiles.c
@@ -848,6 +848,12 @@ static char **ssh_get_knownhost_line(SSH_SESSION *session,FILE **file, char *fil
if(!buffer[0] || buffer[0]=='#')
continue; /* skip empty lines */
tokens=space_tokenize(buffer);
+ if (tokens == NULL) {
+ fclose(*file);
+ *file = NULL;
+ leave_function();
+ return NULL;
+ }
if(!tokens[0] || !tokens[1] || !tokens[2]){
/* it should have at least 3 tokens */
tokens_free(tokens);
@@ -870,6 +876,8 @@ static char **ssh_get_knownhost_line(SSH_SESSION *session,FILE **file, char *fil
continue;
}
}
+ fclose(*file);
+ *file = NULL;
leave_function();
return tokens;
}