Subject: Re: Problem with known_hosts

Re: Problem with known_hosts

From: Pierre-Yves Fontaniere <>
Date: Thu, 03 Mar 2011 16:33:15 +0100

On 03/03/2011 03:04 PM, Alexander Lamaison wrote:
> On 2 March 2011 15:22, Pierre-Yves Fontaniere<> wrote:
>> I'm not really used to provide patches, and i'm working on AIX also, so the
>> way of doing a patch is somewhat different :)
>> File provided is from a "diff -c".
> The best way to provide the patch is using git diff. This preserves
> the log and authorship information in a way that can simply be
> comitted as-is.
> Failing that, please provide the patch from `diff -u`. Context diffs
> can be hard to read for humans.
Yep I know, but there's no option -u in "AIX genuine diff" and AIX patch
doesn't work with unified context patch... I will install GNU diff and
patch tools . :)
I attached a diff -u patch to this mail
>> - Some lines to really remove ending '\n' directly when reading lines from
>> knownhosts file.
> Can you explain a bit more about this? What was the code doing wrong before?
In fact, the code wasn't doing something wrong. But when i was
debugging, i saw (with simple printf) keys with leading '\n'. So I
thought first the problem was here. I saw later that was not the case
but even if i know that there's no use of function like strlen in the
code, i prefer having a '\n' leading free and zero terminated string.

libssh2_knownhost_readfile is the only place where we use something else
than const char *. So this is the place to format every line and have
zero terminated string without leading '\n'.
I used strrchr which take the buffer from the end and doesn't browse all
the key from the beginning (like it is done later in

I let you decide if it is an interesting modification or not. :)
>> - A section to handle correctly multiple hostnames, aliases, IP addr on the
>> same line in knownhosts file.
> For my testing, can you send me an example of what one of these AIX
> entries with multiple aliases contains?
This is not specific to AIX :) we use this kind of knownhosts entries on
Linux, Solaris and AIX.

Entry like :




Received on 2011-03-03