Page MenuHomePhabricator

ssh_set_channel_callbacks() does not create a copy of ssh_channel_callbacks_struct, while documentation implies otherwise
Closed, ResolvedPublic


ssh_set_channel_callbacks(), and probably the other ssh_set_*_callbacks() functions, don't seem to make a copy of their argument, the struct holding all the callbacks. In my own code, I would set the callbacks in one function, then return and call the rest of the channel functions later. Since I followed the example in the documentation for ssh_set_channel_callbacks(), which just creates a ssh_channel_callbacks_struct on the stack, this eventually caused a segfault whenever libssh tried to use one of my callbacks.

Either the documentation should be updated to explicitly state that the struct passed to ssh_set_channel_callbacks() must remain valid for as long as the channel is valid, or the code should be updated to make a copy of the ssh_channel_callbacks_struct.

Event Timeline

marekp0 triaged this task as Normal priority.Sep 9 2018, 5:18 AM
marekp0 created this task.
Jakuje added a project: Restricted Project.Sep 25 2019, 4:00 PM
Jakuje added a subscriber: Jakuje.

I think we should update the documentation so it is clear that the structure needs to be valid as long as the channel/session is valid.

Can you check if something like this would help you when reading the documentation or can you propose better wording?