Subject: Re: knownhost.c hostline() fix

Re: knownhost.c hostline() fix

From: Ben Kibbey <bjk_at_luxsci.net>
Date: Wed, 10 Jun 2009 18:30:23 -0400

On Wed, Jun 10, 2009 at 08:49:32PM +0200, Daniel Stenberg wrote:
> On Mon, 8 Jun 2009, Ben Kibbey wrote:
>
> > This fixes hostname parsing when only one part is given in the host portion:
>
> Thanks a lot, applied!

Sure. glad to help. Here's a minor fix for writing a null byte at the
end of a line in the known host file:

diff --git a/src/knownhost.c b/src/knownhost.c
index 525f60f..bea62ab 100644
--- a/src/knownhost.c
+++ b/src/knownhost.c
@@ -791,8 +791,8 @@ libssh2_knownhost_writefile(LIBSSH2_KNOWNHOSTS *hosts,
         if(rc)
             break;
 
- nwrote = fwrite(buffer, 1, wrote, file);
- if(nwrote != wrote) {
+ nwrote = fprintf(file, "%s", buffer);
+ if(nwrote != wrote-1) {
             /* failed to write the whole thing, bail out */
             rc = LIBSSH2_ERROR_FILE;
             break;

-- 
Ben Kibbey (bjk) @ FreeNode/OFTC/Jabber
KeyID: 0xF2B33BEF
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
libssh2-devel mailing list
libssh2-devel_at_lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libssh2-devel
Received on 2009-06-11