From ffd06b1cd014dbfeb50c3ef9041f077ef088614a Mon Sep 17 00:00:00 2001 From: Nuhiat-Arefin Date: Thu, 9 Apr 2026 23:47:33 +0600 Subject: [PATCH] fix: initialize known_hosts output entry ssh_session_get_known_hosts_entry() could return SSH_KNOWN_HOSTS_OK without initializing *pentry, leaving callers with an undefined output pointer. Initialize *pentry to NULL at function entry so every return path leaves the output in a defined state. Signed-off-by: Nuhiat-Arefin Reviewed-by: Jakub Jelen Merge-Request: (cherry picked from commit 6cd0e6e52a5e5445dea52ffa4ed696d296f1713d) --- src/knownhosts.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/knownhosts.c b/src/knownhosts.c index a12c3b42..6d42f7a7 100644 --- a/src/knownhosts.c +++ b/src/knownhosts.c @@ -1183,6 +1183,10 @@ ssh_session_get_known_hosts_entry(ssh_session session, { enum ssh_known_hosts_e old_rv, rv = SSH_KNOWN_HOSTS_UNKNOWN; + if (pentry != NULL) { + *pentry = NULL; + } + if (session->opts.knownhosts == NULL) { if (ssh_options_apply(session) < 0) { ssh_set_error(session,