diff options
author | doug@openbsd.org <doug@openbsd.org> | 2014-08-21 01:08:52 +0000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2014-10-13 11:37:21 +1100 |
commit | 7df8818409c752cf3f0c3f8044fe9aebed8647bd (patch) | |
tree | d5fd861ecaf40e6d0441d37f2cca85739c876876 /ssh-keygen.c | |
parent | 40ba4c9733aaed08304714faeb61529f18da144b (diff) |
upstream commit
Free resources on error in mkstemp and fdopen
ok djm@
Diffstat (limited to 'ssh-keygen.c')
-rw-r--r-- | ssh-keygen.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/ssh-keygen.c b/ssh-keygen.c index 23058ee99..e149eda3e 100644 --- a/ssh-keygen.c +++ b/ssh-keygen.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssh-keygen.c,v 1.249 2014/07/03 03:47:27 djm Exp $ */ | 1 | /* $OpenBSD: ssh-keygen.c,v 1.250 2014/08/21 01:08:52 doug Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -967,12 +967,14 @@ do_gen_all_hostkeys(struct passwd *pw) | |||
967 | f = fdopen(fd, "w"); | 967 | f = fdopen(fd, "w"); |
968 | if (f == NULL) { | 968 | if (f == NULL) { |
969 | printf("fdopen %s failed\n", identity_file); | 969 | printf("fdopen %s failed\n", identity_file); |
970 | close(fd); | ||
970 | key_free(public); | 971 | key_free(public); |
971 | first = 0; | 972 | first = 0; |
972 | continue; | 973 | continue; |
973 | } | 974 | } |
974 | if (!key_write(public, f)) { | 975 | if (!key_write(public, f)) { |
975 | fprintf(stderr, "write key failed\n"); | 976 | fprintf(stderr, "write key failed\n"); |
977 | fclose(f); | ||
976 | key_free(public); | 978 | key_free(public); |
977 | first = 0; | 979 | first = 0; |
978 | continue; | 980 | continue; |