aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVic Lee <llyzs@163.com>2009-12-22 21:09:38 +0800
committerAndreas Schneider <mail@cynapses.org>2009-12-23 09:37:59 +0100
commit5a95681f01be1872a3c7711898fbce00b219c4c6 (patch)
tree7d6abcec97e889b0e06a5cecd983ac2165044b05
parent13a3619102745603edadfecd73d18b44e41927d0 (diff)
downloadlibssh-5a95681f01be1872a3c7711898fbce00b219c4c6.tar.gz
libssh-5a95681f01be1872a3c7711898fbce00b219c4c6.tar.xz
libssh-5a95681f01be1872a3c7711898fbce00b219c4c6.zip
File handle need to be closed in case of errors in privatekey_from_file
Signed-off-by: Vic Lee <llyzs@163.com> Signed-off-by: Andreas Schneider <mail@cynapses.org>
-rw-r--r--libssh/keyfiles.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/libssh/keyfiles.c b/libssh/keyfiles.c
index b13643ad..47904147 100644
--- a/libssh/keyfiles.c
+++ b/libssh/keyfiles.c
@@ -669,6 +669,7 @@ ssh_private_key privatekey_from_file(ssh_session session, const char *filename,
if (type == 0) {
type = privatekey_type_from_file(file);
if (type == 0) {
+ fclose(file);
ssh_set_error(session, SSH_FATAL, "Invalid private key file.");
return NULL;
}
@@ -755,6 +756,7 @@ ssh_private_key privatekey_from_file(ssh_session session, const char *filename,
}
break;
default:
+ fclose(file);
ssh_set_error(session, SSH_FATAL, "Invalid private key type %d", type);
return NULL;
} /* switch */