Page MenuHomePhabricator

ssh_set_channel_callbacks() does not create a copy of ssh_channel_callbacks_struct, while documentation implies otherwise
Open, NormalPublic

Description

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 created this task.Sep 9 2018, 5:18 AM
marekp0 triaged this task as Normal priority.