[openssh-commits] [openssh] 01/02: upstream: fix a bug I introduced in r1.406: when printing private key

git+noreply at mindrot.org git+noreply at mindrot.org
Mon Apr 20 14:47:32 AEST 2020


This is an automated email from the git hooks/post-receive script.

djm pushed a commit to branch master
in repository openssh.

commit a98d5ba31e5e7e01317352f85fa63b846a960f8c
Author: djm at openbsd.org <djm at openbsd.org>
Date:   Mon Apr 20 04:43:57 2020 +0000

    upstream: fix a bug I introduced in r1.406: when printing private key
    
    fingerprint of old-format key, key comments were not being displayed. Spotted
    by loic AT venez.fr, ok dtucker
    
    OpenBSD-Commit-ID: 2d98e4f9eb168eea733d17e141e1ead9fe26e533
---
 ssh-keygen.c | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/ssh-keygen.c b/ssh-keygen.c
index c181b58a..d50ca5f2 100644
--- a/ssh-keygen.c
+++ b/ssh-keygen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh-keygen.c,v 1.406 2020/04/17 07:16:07 djm Exp $ */
+/* $OpenBSD: ssh-keygen.c,v 1.407 2020/04/20 04:43:57 djm Exp $ */
 /*
  * Author: Tatu Ylonen <ylo at cs.hut.fi>
  * Copyright (c) 1994 Tatu Ylonen <ylo at cs.hut.fi>, Espoo, Finland
@@ -910,21 +910,25 @@ fingerprint_private(const char *path)
 {
 	struct stat st;
 	char *comment = NULL;
-	struct sshkey *key = NULL;
+	struct sshkey *privkey = NULL, *pubkey = NULL;
 	int r;
 
 	if (stat(identity_file, &st) == -1)
 		fatal("%s: %s", path, strerror(errno));
-	if ((r = sshkey_load_private(path, NULL, &key, &comment)) != 0) {
-		debug("load private \"%s\": %s", path, ssh_err(r));
-		if ((r = sshkey_load_public(path, &key, &comment)) != 0) {
-			debug("load public \"%s\": %s", path, ssh_err(r));
-			fatal("%s is not a key file.", path);
-		}
+	if ((r = sshkey_load_public(path, &pubkey, &comment)) != 0)
+		debug("load public \"%s\": %s", path, ssh_err(r));
+	if (pubkey == NULL || comment == NULL || *comment == '\0') {
+		free(comment);
+		if ((r = sshkey_load_private(path, NULL,
+		    &privkey, &comment)) != 0)
+			debug("load private \"%s\": %s", path, ssh_err(r));
 	}
+	if (pubkey == NULL && privkey == NULL)
+		fatal("%s is not a key file.", path);
 
-	fingerprint_one_key(key, comment);
-	sshkey_free(key);
+	fingerprint_one_key(pubkey == NULL ? privkey : pubkey, comment);
+	sshkey_free(pubkey);
+	sshkey_free(privkey);
 	free(comment);
 }
 

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list