aboutsummaryrefslogtreecommitdiff
path: root/libssh/keyfiles.c
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:35 +0100
commitfcda8beb1cbf3e30263fe566bfef625555bdd897 (patch)
tree9307c6a1a85a4365f90c772c1aa78a7f369e2b03 /libssh/keyfiles.c
parentd0647afae50294ec09b3ce7c968c7c6c42f4190d (diff)
downloadlibssh-fcda8beb1cbf3e30263fe566bfef625555bdd897.tar.gz
libssh-fcda8beb1cbf3e30263fe566bfef625555bdd897.tar.xz
libssh-fcda8beb1cbf3e30263fe566bfef625555bdd897.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>
Diffstat (limited to 'libssh/keyfiles.c')
-rw-r--r--libssh/keyfiles.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/libssh/keyfiles.c b/libssh/keyfiles.c
index 8646937..21b02a8 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 */