www.libssh2.org | Daily snapshots | Mailing list archive | Docs | Examples | github

Archive Index This month's Index

Subject: Re: [PATCH] add function libssh2_session_set_last_error

Re: [PATCH] add function libssh2_session_set_last_error

From: Kamil Dudka <kdudka_at_redhat.com>
Date: Mon, 19 Oct 2015 13:50:11 +0200

On Thursday 15 October 2015 17:57:03 Salvador Fandino wrote:
> See the patch attached.
>
> It just exposes _libssh2_error through the API and its immediate
> objective is making my life (as the current maintainer of Net::SSH2)
> much much much easier.
>
> But actually, this function may be useful to anybody building new
> features on top of the library and obviously for other wrapping modules.

Thanks for the patch! I agree that it as a valid reason for extending
the API. Nevertheless, the proposed API looks fragile to me. libssh2
does not copy the error message to its own memory. So it is caller's
responsibility to keep the string valid long enough. This could cause
problems.

We should either change the code to allocate memory for the error message
or clearly specify in the API documentation for how long the string needs
to remain valid.

Kamil
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2015-10-19

the libssh2 team