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 <james@puiterwijk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
JamesWrigley
2024-03-11 15:22:21 +01:00
committed by Jakub Jelen
parent c4e547f3f7
commit 6c59d975ba

View File

@@ -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;
}