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 <nuhiatarefin@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/814>
This commit is contained in:
Nuhiat-Arefin
2026-04-09 23:47:33 +06:00
committed by Jakub Jelen
parent 854e9823f5
commit 6cd0e6e52a

View File

@@ -1182,6 +1182,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,