From bf25c7a354cb3d38f1f623e00f00ab4a4cc1315c Mon Sep 17 00:00:00 2001 From: djm Date: Fri, 13 Jan 2023 02:44:02 +0000 Subject: [PATCH] avoid printf("%s", NULL) if using ssh -oUserKnownHostsFile=none and a hostkey in one of the system known hosts file changes; ok dtucker@ --- usr.bin/ssh/sshconnect.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/usr.bin/ssh/sshconnect.c b/usr.bin/ssh/sshconnect.c index f5bdd35889b..3464e280f4d 100644 --- a/usr.bin/ssh/sshconnect.c +++ b/usr.bin/ssh/sshconnect.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sshconnect.c,v 1.360 2022/11/03 21:59:20 djm Exp $ */ +/* $OpenBSD: sshconnect.c,v 1.361 2023/01/13 02:44:02 djm Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -1238,8 +1238,11 @@ check_host_key(char *hostname, const struct ssh_conn_info *cinfo, } /* The host key has changed. */ warn_changed_key(host_key); - error("Add correct host key in %.100s to get rid of this message.", - user_hostfiles[0]); + if (num_user_hostfiles > 0 || num_system_hostfiles > 0) { + error("Add correct host key in %.100s to get rid " + "of this message.", num_user_hostfiles > 0 ? + user_hostfiles[0] : system_hostfiles[0]); + } error("Offending %s key in %s:%lu", sshkey_type(host_found->key), host_found->file, host_found->line); -- 2.20.1