aboutsummaryrefslogtreecommitdiff
path: root/libssh/keyfiles.c
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2010-07-23 11:01:06 +0200
committerAris Adamantiadis <aris@0xbadc0de.be>2010-07-23 11:01:06 +0200
commite721c122d3f453094d4ab27040765974620f15ef (patch)
tree5ef53f6dbd202e07c1b01748b76d76dff292c4ec /libssh/keyfiles.c
parent8cd0d0040e70b5a1ab0a8d8588190dd88f17ce4f (diff)
downloadlibssh-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.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/libssh/keyfiles.c b/libssh/keyfiles.c
index df1e24f5..f715d25a 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) {