[PATCH] OpenSSH_7.1p1: ssh-keygen -R leaks a temp file if there is no known_hosts file
Craig Leres
leres at ee.lbl.gov
Thu Nov 26 04:00:10 AEDT 2015
For example:
$ ls ~/.ssh/known_hosts.*
ls: /home/fun/u0/leres/.ssh/known_hosts.*: No such file or directory
$ ssh-keygen -R `hostname`
do_known_hosts: hostkeys_foreach failed: No such file or directory
$ ls ~/.ssh/known_hosts.*
/home/fun/u0/leres/.ssh/known_hosts.TZJ7CQ0iiH
The attached patch corrects this.
Craig
-------------- next part --------------
--- ssh-keygen.c.orig 2015-11-25 08:14:19.000000000 -0800
+++ ssh-keygen.c 2015-11-25 08:22:07.000000000 -0800
@@ -1185,8 +1185,11 @@
foreach_options |= print_fingerprint ? HKF_WANT_PARSE_KEY : 0;
if ((r = hostkeys_foreach(identity_file,
hash_hosts ? known_hosts_hash : known_hosts_find_delete, &ctx,
- name, NULL, foreach_options)) != 0)
+ name, NULL, foreach_options)) != 0) {
+ if (inplace)
+ unlink(tmp);
fatal("%s: hostkeys_foreach failed: %s", __func__, ssh_err(r));
+ }
if (inplace)
fclose(ctx.out);
More information about the openssh-unix-dev
mailing list