Ticket #27 (closed defect: fixed)

Opened 10 years ago

Last modified 2 years ago

libssh2_userauth_list returns a pointer to internal buffer

Reported by: sambira Owned by: Viktor Szakats <vszakats@…>
Priority: normal Milestone:
Component: API Version:
Keywords: Cc: sambira, bagder
Blocked By: Blocks:


This API returns to the caller a buffer pointer that was allocated internally by the API and requires the user to free. This is not good when overloading the allocate functions and the allocate is different than the free. The API needs to require the user to either pass in a buffer to house the data or copy the data into their space or risk loosing the data. I would opt for the later where the API does not change but the semantics of operation do. The library API should then use an internal fixed buffer (maybe a stack buffer) to wearhouse the data and pass that pointer. When the function is done, the data is gone. Another option is to have the session structure contain a buffer for this information which the user can access since they have the pointer to the session buffer and the structure access to reference data from there (maybe provide a MACRO to access the information). Just some thoughts.


Mark Wick

Change History

comment:1 Changed 10 years ago by bagder

No, the returned string should NOT be freed by the application but is handled by the library itself, as is now also mentioned in the man page included in the 0.15 release.

comment:2 Changed 2 years ago by Viktor Szakats <vszakats@…>

  • Owner set to Viktor Szakats <vszakats@…>
  • Resolution set to fixed

In a4d995af0dc8784011c06a9f78d05b681caf7fd7/libssh2:

GNUmakefile: add support for LIBSSH2_LDFLAG_EXTRAS

It is similar to existing LIBSSH2_CFLAG_EXTRAS, but for
extra linker options.

Also delete some line/file ending whitespace.

closes #27

Note: See TracTickets for help on using tickets.