summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordoug@openbsd.org <doug@openbsd.org>2014-08-21 01:08:52 +0000
committerDamien Miller <djm@mindrot.org>2014-10-13 11:37:21 +1100
commit7df8818409c752cf3f0c3f8044fe9aebed8647bd (patch)
treed5fd861ecaf40e6d0441d37f2cca85739c876876
parent40ba4c9733aaed08304714faeb61529f18da144b (diff)
upstream commit
Free resources on error in mkstemp and fdopen ok djm@
-rw-r--r--moduli.c3
-rw-r--r--ssh-keygen.c4
2 files changed, 5 insertions, 2 deletions
diff --git a/moduli.c b/moduli.c
index bb4dd7beb..474caca67 100644
--- a/moduli.c
+++ b/moduli.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: moduli.c,v 1.28 2013/10/24 00:49:49 dtucker Exp $ */ 1/* $OpenBSD: moduli.c,v 1.29 2014/08/21 01:08:52 doug Exp $ */
2/* 2/*
3 * Copyright 1994 Phil Karn <karn@qualcomm.com> 3 * Copyright 1994 Phil Karn <karn@qualcomm.com>
4 * Copyright 1996-1998, 2003 William Allen Simpson <wsimpson@greendragon.com> 4 * Copyright 1996-1998, 2003 William Allen Simpson <wsimpson@greendragon.com>
@@ -461,6 +461,7 @@ write_checkpoint(char *cpfile, u_int32_t lineno)
461 } 461 }
462 if ((fp = fdopen(r, "w")) == NULL) { 462 if ((fp = fdopen(r, "w")) == NULL) {
463 logit("write_checkpoint: fdopen: %s", strerror(errno)); 463 logit("write_checkpoint: fdopen: %s", strerror(errno));
464 unlink(tmp);
464 close(r); 465 close(r);
465 return; 466 return;
466 } 467 }
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;