From 45567bebb757ac1832999d15184a15bfd7d84671 Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Wed, 6 May 2026 23:29:31 +0100 Subject: [PATCH] ssh: only allow not found (nonexistent) HOME Only succeed if the HOME directory is not found. Otherwise, error. --- src/libgit2/transports/ssh_libssh2.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/libgit2/transports/ssh_libssh2.c b/src/libgit2/transports/ssh_libssh2.c index d71cc75b7..d395bd22d 100644 --- a/src/libgit2/transports/ssh_libssh2.c +++ b/src/libgit2/transports/ssh_libssh2.c @@ -439,7 +439,13 @@ static int load_known_hosts(LIBSSH2_KNOWNHOSTS **hosts, LIBSSH2_SESSION *session GIT_ASSERT_ARG(hosts); - git_sysdir_expand_homedir_file(&sshdir, SSH_DIR); + if ((error = git_sysdir_expand_homedir_file(&sshdir, SSH_DIR)) < 0) { + if (error == GIT_ENOTFOUND) + error = 0; + + goto out; + } + if ((error = git_str_joinpath(&path, git_str_cstr(&sshdir), KNOWN_HOSTS_FILE)) < 0) goto out;