1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-11-30 13:01:23 +03:00

knownhosts: Fix use after free

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Andreas Schneider
2019-06-12 10:17:26 +02:00
parent 77ada9e4dc
commit 1a3436d7d3

View File

@@ -775,12 +775,14 @@ int ssh_session_update_known_hosts(ssh_session session)
} else { } else {
rc = 0; rc = 0;
} }
SAFE_FREE(dir);
if (rc != 0) { if (rc != 0) {
ssh_set_error(session, SSH_FATAL, ssh_set_error(session, SSH_FATAL,
"Cannot create %s directory.", dir); "Cannot create %s directory.", dir);
SAFE_FREE(dir);
return SSH_ERROR; return SSH_ERROR;
} }
SAFE_FREE(dir);
fp = fopen(session->opts.knownhosts, "a"); fp = fopen(session->opts.knownhosts, "a");
if (fp == NULL) { if (fp == NULL) {