[PATCH] OpenSSH_7.1p1: ssh-keygen -R leaks a temp file if there is no known_hosts file

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

 



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
--- 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);
_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev@xxxxxxxxxxx
https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux