From 6c59d975babdc9cfc62223f91326ca4a81178179 Mon Sep 17 00:00:00 2001 From: JamesWrigley Date: Mon, 11 Mar 2024 15:22:21 +0100 Subject: [PATCH] Poll the channel in ssh_channel_poll() when the buffer isn't empty Previously the call to ssh_handle_packets() would be skipped if the buffer wasn't empty. This meant that if ssh_channel_poll() was called on a non-blocking channel with callbacks to handle incoming data, and the buffer already had some data, the callbacks would never be called. Signed-off-by: James Wrigley Reviewed-by: Jakub Jelen Reviewed-by: Andreas Schneider --- src/channels.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/channels.c b/src/channels.c index 7370d498..770bd57a 100644 --- a/src/channels.c +++ b/src/channels.c @@ -3239,6 +3239,8 @@ int ssh_channel_read_nonblocking(ssh_channel channel, /** * @brief Polls a channel for data to read. * + * If callbacks are set on the channel, they will be called. + * * @param[in] channel The channel to poll. * * @param[in] is_stderr A boolean to select the stderr stream. @@ -3266,7 +3268,7 @@ int ssh_channel_poll(ssh_channel channel, int is_stderr) stdbuf = channel->stderr_buffer; } - if (ssh_buffer_get_len(stdbuf) == 0 && channel->remote_eof == 0) { + if (channel->remote_eof == 0) { if (channel->session->session_state == SSH_SESSION_STATE_ERROR){ return SSH_ERROR; }