From b9530cedbeb169762307096dfeb485ab94e09740 Mon Sep 17 00:00:00 2001 From: Anderson Toshiyuki Sasaki Date: Fri, 28 Jun 2019 13:27:34 +0200 Subject: [PATCH] knownhosts: Read knownhosts file only if found Avoid trying to open the files if they are not accessible. This was already treated as a non-error, but with this we save one function call. Signed-off-by: Anderson Toshiyuki Sasaki Reviewed-by: Jakub Jelen (cherry picked from commit e5a64a3d6b1b601cbaf207468a6658d1a4fa0031) --- src/knownhosts.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/knownhosts.c b/src/knownhosts.c index 9383cc97..8040a0c0 100644 --- a/src/knownhosts.c +++ b/src/knownhosts.c @@ -691,7 +691,7 @@ enum ssh_known_hosts_e ssh_session_has_known_hosts_entry(ssh_session session) return SSH_KNOWN_HOSTS_ERROR; } - if (session->opts.knownhosts != NULL) { + if (known_hosts_found) { rc = ssh_known_hosts_read_entries(host_port, session->opts.knownhosts, &entry_list); @@ -702,7 +702,7 @@ enum ssh_known_hosts_e ssh_session_has_known_hosts_entry(ssh_session session) } } - if (session->opts.global_knownhosts != NULL) { + if (global_known_hosts_found) { rc = ssh_known_hosts_read_entries(host_port, session->opts.global_knownhosts, &entry_list);