[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Patch] Potential file hander leak in privatekey_from_file
[Thread Prev] | [Thread Next]
- Subject: [Patch] Potential file hander leak in privatekey_from_file
- From: Vic Lee <llyzs@xxxxxxx>
- Reply-to: libssh@xxxxxxxxxx
- Date: Tue, 22 Dec 2009 21:14:53 +0800
- To: libssh <libssh@xxxxxxxxxx>
Hi, This quick patch is just to fclose the file handler in case of error exit in function privatekey_from_file, a bug introduced in my last patch. Thanks, Vic
From 800851aacbb6106f58c3f3545489f9b3f41fb9ba Mon Sep 17 00:00:00 2001
From: Vic Lee <llyzs@xxxxxxx>
Date: Tue, 22 Dec 2009 21:09:38 +0800
Subject: [PATCH] File handle need to be closed in case of errors in privatekey_from_file
Signed-off-by: Vic Lee <llyzs@xxxxxxx>
---
libssh/keyfiles.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/libssh/keyfiles.c b/libssh/keyfiles.c
index b13643a..4790414 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 */
--
1.6.5
Archive administrator: postmaster@lists.cynapses.org