summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelen <jjelen@redhat.com>2019-09-13 13:14:35 +0200
committerJakub Jelen <jjelen@redhat.com>2019-09-16 09:35:24 +0200
commit83fa060cec0f3c062117807b154a18f2db63ef06 (patch)
tree0014ac65b7b8ecc5c310417fba1974bd4a2669d7
parent4799915a365972bffebc301193978d709500daec (diff)
downloadlibssh-83fa060cec0f3c062117807b154a18f2db63ef06.tar.gz
libssh-83fa060cec0f3c062117807b154a18f2db63ef06.tar.xz
libssh-83fa060cec0f3c062117807b154a18f2db63ef06.zip
known_hosts: Avoid using deprecated functions (even from deprecated functions)
Fixes: T165 Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
-rw-r--r--src/known_hosts.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/known_hosts.c b/src/known_hosts.c
index 9a09d1c4..ec6da308 100644
--- a/src/known_hosts.c
+++ b/src/known_hosts.c
@@ -405,8 +405,12 @@ int ssh_is_server_known(ssh_session session)
if ((ret == SSH_SERVER_NOT_KNOWN) &&
(session->opts.StrictHostKeyChecking == 0)) {
- ssh_write_knownhost(session);
- ret = SSH_SERVER_KNOWN_OK;
+ int rv = ssh_session_update_known_hosts(session);
+ if (rv != SSH_OK) {
+ ret = SSH_SERVER_ERROR;
+ } else {
+ ret = SSH_SERVER_KNOWN_OK;
+ }
}
SAFE_FREE(host);
@@ -492,9 +496,10 @@ char * ssh_dump_knownhost(ssh_session session) {
* @deprecated Please use ssh_session_update_known_hosts()
* @brief This function is deprecated
*/
-int ssh_write_knownhost(ssh_session session) {
+int ssh_write_knownhost(ssh_session session)
+{
FILE *file;
- char *buffer;
+ char *buffer = NULL;
char *dir;
int rc;
@@ -542,8 +547,8 @@ int ssh_write_knownhost(ssh_session session) {
}
}
- buffer = ssh_dump_knownhost(session);
- if (buffer == NULL) {
+ rc = ssh_session_export_known_hosts_entry(session, &buffer);
+ if (rc != SSH_OK) {
fclose(file);
return SSH_ERROR;
}