On 10/19/2015 01:50 PM, Kamil Dudka wrote:
> 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
> 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.
Two new patches are attached.
As I didn't want to penalize every calls to "_libssh2_error" with a
"strdup", I converted it into "_libssh2_error_flags" which accepts a
flag indicating whether the given string must be duplicated and then
added a new "_libssh2_error" that just calls "_libssh2_error_flags".
Finally, the second patch adds "libssh2_session_set_last_error" to the
public API. It relies on "_libssh2_error_flags" and always duplicates
the given string.
Received on 2015-10-22
- application/text attachment: stored