On 3 March 2011 15:33, Pierre-Yves Fontaniere <pyf_at_cc.in2p3.fr> wrote:
> On 03/03/2011 03:04 PM, Alexander Lamaison wrote:
>> On 2 March 2011 15:22, Pierre-Yves Fontaniere<pyf_at_cc.in2p3.fr> wrote:
>>> - Some lines to really remove ending '\n' directly when reading lines
>>> knownhosts file.
>> Can you explain a bit more about this? What was the code doing wrong
> 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.
I still don't understand what you mean. Where are you seeing these
leading '\n's? The existing code extracts the key from the file
without including any '\n'. What has strlen got to do with it?
> 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'm lost. What is the relevance of const char*?
libssh2_knownhost_readline doesn't change the contents of the line so
it doesn't matter that it's const char*.
> 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
Your code tries to replace '\n' with '\0' before reading the entry but
this isn't necessary as hostline takes a key and a keylength. It
doesn't treat the key as a terminated string. You can terminate it
with anything you like and, as long as the length is correct, it will
> I let you decide if it is an interesting modification or not. :)
I'm afraid not. It does extra work and breaks the behaviour of
libssh2_knownhost_readline, a public API function. When passed a line
that ends in '\n', libssh2_knownhost_readline now adds the key to the
collection with the newline still present. This is wrong.
>> 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 :
> ccsmurf,ccsvli05,ccsvli05.in2p3.fr,ccsmurf.in2p3.fr,184.108.40.206 ssh-rsa
Thanks. I will do some more testing using this entry at some point this week.
Swish - Easy SFTP for Windows Explorer (http://www.swish-sftp.org)
Received on 2011-03-07