diff options
author | Aris Adamantiadis <aris@0xbadc0de.be> | 2010-07-23 11:01:06 +0200 |
---|---|---|
committer | Aris Adamantiadis <aris@0xbadc0de.be> | 2010-07-23 11:01:06 +0200 |
commit | e721c122d3f453094d4ab27040765974620f15ef (patch) | |
tree | 5ef53f6dbd202e07c1b01748b76d76dff292c4ec /libssh/keyfiles.c | |
parent | 8cd0d0040e70b5a1ab0a8d8588190dd88f17ce4f (diff) | |
download | libssh-e721c122d3f453094d4ab27040765974620f15ef.tar.gz libssh-e721c122d3f453094d4ab27040765974620f15ef.tar.xz libssh-e721c122d3f453094d4ab27040765974620f15ef.zip |
Continue removing old flushing code
Diffstat (limited to 'libssh/keyfiles.c')
-rw-r--r-- | libssh/keyfiles.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/libssh/keyfiles.c b/libssh/keyfiles.c index df1e24f..f715d25 100644 --- a/libssh/keyfiles.c +++ b/libssh/keyfiles.c @@ -1700,7 +1700,7 @@ int ssh_is_server_known(ssh_session session) { * @return SSH_OK on success, SSH_ERROR on error. */ int ssh_write_knownhost(ssh_session session) { - ssh_string pubkey = session->current_crypto->server_pubkey; + ssh_string pubkey; unsigned char *pubkey_64; char buffer[4096] = {0}; FILE *file; @@ -1727,10 +1727,21 @@ int ssh_write_knownhost(ssh_session session) { if (session->knownhosts == NULL) { if (ssh_options_apply(session) < 0) { ssh_set_error(session, SSH_FATAL, "Can't find a known_hosts file"); - return -1; + return SSH_ERROR; } } + if(session->current_crypto==NULL) { + ssh_set_error(session, SSH_FATAL, "No current crypto context"); + return SSH_ERROR; + } + + pubkey = session->current_crypto->server_pubkey; + if(pubkey == NULL){ + ssh_set_error(session, SSH_FATAL, "No public key present"); + return SSH_ERROR; + } + /* Check if ~/.ssh exists and create it if not */ dir = ssh_dirname(session->knownhosts); if (dir == NULL) { |