From e9931ce216a68f2d1b100235ee62a5d69670d5be Mon Sep 17 00:00:00 2001 From: djm Date: Fri, 31 Mar 2023 04:21:56 +0000 Subject: [PATCH] don't print key if printing hostname failed; with/ok dtucker@ --- usr.bin/ssh/ssh-keyscan.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/usr.bin/ssh/ssh-keyscan.c b/usr.bin/ssh/ssh-keyscan.c index f40686961d4..159023dc2ee 100644 --- a/usr.bin/ssh/ssh-keyscan.c +++ b/usr.bin/ssh/ssh-keyscan.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh-keyscan.c,v 1.151 2023/02/10 06:41:53 jmc Exp $ */ +/* $OpenBSD: ssh-keyscan.c,v 1.152 2023/03/31 04:21:56 djm Exp $ */ /* * Copyright 1995, 1996 by David Mazieres . * @@ -293,6 +293,7 @@ keyprint_one(const char *host, struct sshkey *key) { char *hostport = NULL, *hashed = NULL; const char *known_host; + int r = 0; found_one = 1; @@ -307,9 +308,9 @@ keyprint_one(const char *host, struct sshkey *key) fatal("host_hash failed"); known_host = hash_hosts ? hashed : hostport; if (!get_cert) - fprintf(stdout, "%s ", known_host); - sshkey_write(key, stdout); - fputs("\n", stdout); + r = fprintf(stdout, "%s ", known_host); + if (r >= 0 && sshkey_write(key, stdout) == 0) + (void)fputs("\n", stdout); free(hashed); free(hostport); } -- 2.20.1