mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-12-02 01:17:52 +03:00
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>
This commit is contained in:
committed by
Andreas Schneider
parent
d0647afae5
commit
fcda8beb1c
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user