1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-10 09:58:01 +00:00

Avoid leaking file handles in load_openssh_key(), as reported by David

Wedderwille.

[originally from svn r9642]
This commit is contained in:
Simon Tatham 2012-08-30 18:44:33 +00:00
parent ddfca43402
commit e2a48fe9b1

View File

@ -321,7 +321,7 @@ static struct openssh_key *load_openssh_key(const Filename *filename,
const char **errmsg_p) const char **errmsg_p)
{ {
struct openssh_key *ret; struct openssh_key *ret;
FILE *fp; FILE *fp = NULL;
char *line = NULL; char *line = NULL;
char *errmsg, *p; char *errmsg, *p;
int headers_done; int headers_done;
@ -453,6 +453,9 @@ static struct openssh_key *load_openssh_key(const Filename *filename,
line = NULL; line = NULL;
} }
fclose(fp);
fp = NULL;
if (ret->keyblob_len == 0 || !ret->keyblob) { if (ret->keyblob_len == 0 || !ret->keyblob) {
errmsg = "key body not present"; errmsg = "key body not present";
goto error; goto error;
@ -483,6 +486,7 @@ static struct openssh_key *load_openssh_key(const Filename *filename,
sfree(ret); sfree(ret);
} }
if (errmsg_p) *errmsg_p = errmsg; if (errmsg_p) *errmsg_p = errmsg;
if (fp) fclose(fp);
return NULL; return NULL;
} }