1
0
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:
Vic Lee
2009-12-22 21:09:38 +08:00
committed by Andreas Schneider
parent d0647afae5
commit fcda8beb1c

View File

@@ -669,6 +669,7 @@ ssh_private_key privatekey_from_file(ssh_session session, const char *filename,
if (type == 0) { if (type == 0) {
type = privatekey_type_from_file(file); type = privatekey_type_from_file(file);
if (type == 0) { if (type == 0) {
fclose(file);
ssh_set_error(session, SSH_FATAL, "Invalid private key file."); ssh_set_error(session, SSH_FATAL, "Invalid private key file.");
return NULL; return NULL;
} }
@@ -755,6 +756,7 @@ ssh_private_key privatekey_from_file(ssh_session session, const char *filename,
} }
break; break;
default: default:
fclose(file);
ssh_set_error(session, SSH_FATAL, "Invalid private key type %d", type); ssh_set_error(session, SSH_FATAL, "Invalid private key type %d", type);
return NULL; return NULL;
} /* switch */ } /* switch */