From: djm Date: Fri, 31 Mar 2023 04:21:56 +0000 (+0000) Subject: don't print key if printing hostname failed; with/ok dtucker@ X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=e9931ce216a68f2d1b100235ee62a5d69670d5be;p=openbsd don't print key if printing hostname failed; with/ok dtucker@ --- 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); }