aboutsummaryrefslogtreecommitdiff
path: root/src/pki.c
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2013-06-17 11:49:13 +0200
committerAndreas Schneider <asn@cryptomilk.org>2013-06-17 11:49:13 +0200
commit6f8b5ed679876427c4b2ff17b60a7fa3cbd02a54 (patch)
tree3b6c22fe20fbbf1728346f82ed3778d52677f2e7 /src/pki.c
parentd255d1bf328d534bb5b7f5cbc8568448c726d563 (diff)
downloadlibssh-6f8b5ed679876427c4b2ff17b60a7fa3cbd02a54.tar.gz
libssh-6f8b5ed679876427c4b2ff17b60a7fa3cbd02a54.tar.xz
libssh-6f8b5ed679876427c4b2ff17b60a7fa3cbd02a54.zip
pki: Fix a resource leak on error.
Diffstat (limited to 'src/pki.c')
-rw-r--r--src/pki.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/pki.c b/src/pki.c
index ff03138d..e08ed4d4 100644
--- a/src/pki.c
+++ b/src/pki.c
@@ -430,6 +430,7 @@ int ssh_pki_import_privkey_file(const char *filename,
rc = fstat(fileno(file), &sb);
if (rc < 0) {
+ fclose(file);
ssh_pki_log("Error getting stat of %s: %s",
filename, strerror(errno));
switch (errno) {
@@ -813,6 +814,7 @@ int ssh_pki_import_pubkey_file(const char *filename, ssh_key *pkey)
rc = fstat(fileno(file), &sb);
if (rc < 0) {
+ fclose(file);
ssh_pki_log("Error gettint stat of %s: %s",
filename, strerror(errno));
switch (errno) {
@@ -824,6 +826,7 @@ int ssh_pki_import_pubkey_file(const char *filename, ssh_key *pkey)
}
if (sb.st_size > MAX_PUBKEY_SIZE) {
+ fclose(file);
return SSH_ERROR;
}