summaryrefslogtreecommitdiffstats
path: root/libssh/keyfiles.c
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2009-03-29 20:29:55 +0000
committerAris Adamantiadis <aris@0xbadc0de.be>2009-03-29 20:29:55 +0000
commit1fd7a875beca36597e987729bd76928a9593cfd1 (patch)
treebfe02f1180c92c7c806cecd7579fb2d10ffb849a /libssh/keyfiles.c
parent07d748ef5e05b2b03cebde7bd29485946e581c98 (diff)
downloadlibssh-1fd7a875beca36597e987729bd76928a9593cfd1.tar.gz
libssh-1fd7a875beca36597e987729bd76928a9593cfd1.tar.xz
libssh-1fd7a875beca36597e987729bd76928a9593cfd1.zip
Fixed memory leak and file descriptor leak in known host parsing
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@307 7dcaeef0-15fb-0310-b436-a5af3365683c
Diffstat (limited to 'libssh/keyfiles.c')
-rw-r--r--libssh/keyfiles.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/libssh/keyfiles.c b/libssh/keyfiles.c
index 2ce9f86..a4cec4e 100644
--- a/libssh/keyfiles.c
+++ b/libssh/keyfiles.c
@@ -789,13 +789,10 @@ static int alldigits(char *s)
* @{ */
/**
- * @brief Lowercase a string.
- *
- * @param str String to lowercase.
- *
- * @return The lowered string or NULL on error.
- *
- * @internal
+ * \brief Lowercase a string.
+ * \param str String to lowercase.
+ * \return The malloced lowered string or NULL on error.
+ * \internal
*/
static char *lowercase(const char* str) {
char *p = 0;
@@ -1061,13 +1058,12 @@ int ssh_is_server_known(SSH_SESSION *session){
match=check_public_key(session,tokens);
tokens_free(tokens);
if(match<0){
- leave_function();
- return SSH_SERVER_ERROR;
+ ret = SSH_SERVER_ERROR;
+ break;
}
if(match==1){
- fclose(file);
- leave_function();
- return SSH_SERVER_KNOWN_OK;
+ ret=SSH_SERVER_KNOWN_OK;
+ break;
}
if(match==0){
/* We override the status with the wrong key state */
@@ -1076,6 +1072,8 @@ int ssh_is_server_known(SSH_SESSION *session){
}
} while (1);
SAFE_FREE(host);
+ if(file)
+ fclose(file);
/* Return the current state at end of file */
leave_function();
return ret;