Subject: Re: Patch to ticket 228

Re: Patch to ticket 228

From: Henrik Nordström <henrik_at_henriknordstrom.net>
Date: Wed, 26 Oct 2011 01:06:05 +0200

ons 2011-10-26 klockan 00:05 +0200 skrev Daniel Stenberg:

> I only have one comment left here: 'char ***arg' is a really unfortunate
> argument type. I bet that will scare weak-hearted users really good. The least
> we can do is to offer an example in the man page showing how to use it...

It may look scary in the prototype, but normal usage would be

  const char **methods;

  n = libssh2_session_supported_algs(session, type, &methods)

  .... methods[0], .... methods[1], ... methods[n]

  libssh2_free(session, methods);

which is fairly normal.

using *** in the calling code would surely result in confusion.

Other comments

For consistency libssh2_kex_methods should be turned into a function
like how the other types works. Not 100% part of this patch but tightly
related.

Can there really be NULL names within method lists? I do not think so.
kex.c has many loops over these method lists and none skips over NULL
names like done here. Some ends on NULL names, some assumes name is
alway valid.

kex_get_method_by_name() assumes ->name is always valid and would crash
if there is a NULL ->name.

kex_method_strlen() and kex_method_list() truncates the result if ->name
is NULL, and these are used by kexinit to translate the lists into
string lists for the wire protocol.

Regards
Henrik

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2011-10-26