diff options
author | Aris Adamantiadis <aris@0xbadc0de.be> | 2008-11-23 21:39:52 +0000 |
---|---|---|
committer | Aris Adamantiadis <aris@0xbadc0de.be> | 2008-11-23 21:39:52 +0000 |
commit | f880011d727e598561fe64a805a2fb22a39ffcee (patch) | |
tree | 2a8a9190fe12f347edce4e082349d410d1913997 /libssh/keyfiles.c | |
parent | 14c66c9bc504d837dc6a134bfd0628e5c98d210b (diff) | |
download | libssh-f880011d727e598561fe64a805a2fb22a39ffcee.tar.gz libssh-f880011d727e598561fe64a805a2fb22a39ffcee.tar.xz libssh-f880011d727e598561fe64a805a2fb22a39ffcee.zip |
commited path 003 and 004 from Andreas Schneider
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@190 7dcaeef0-15fb-0310-b436-a5af3365683c
Diffstat (limited to 'libssh/keyfiles.c')
-rw-r--r-- | libssh/keyfiles.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/libssh/keyfiles.c b/libssh/keyfiles.c index eb87605..a0b71a4 100644 --- a/libssh/keyfiles.c +++ b/libssh/keyfiles.c @@ -938,6 +938,7 @@ int ssh_write_knownhost(SSH_SESSION *session){ unsigned char *pubkey_64; STRING *pubkey=session->current_crypto->server_pubkey; char buffer[4096]; + size_t len = 0; FILE *file; ssh_options_default_known_hosts_file(session->options); if(!session->options->host){ @@ -992,7 +993,11 @@ int ssh_write_knownhost(SSH_SESSION *session){ snprintf(buffer,sizeof(buffer),"%s %s %s\n",session->options->host,session->current_crypto->server_pubkey_type,pubkey_64); free(pubkey_64); } - fwrite(buffer,strlen(buffer),1,file); + len = strlen(buffer); + if (fwrite(buffer, len, 1, file) != len || ferror(file)) { + fclose(file); + return -1; + } fclose(file); return 0; } |