mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-08-08 19:02:06 +03:00
Fix channel_write to wait during key reexchanges
This commit is contained in:
@@ -1198,6 +1198,20 @@ static int ssh_channel_waitwindow_termination(void *c){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This termination function waits until the session is not in blocked status
|
||||||
|
* anymore, e.g. because of a key re-exchange.
|
||||||
|
*/
|
||||||
|
static int ssh_waitsession_unblocked(void *s){
|
||||||
|
ssh_session session = (ssh_session)s;
|
||||||
|
switch (session->session_state){
|
||||||
|
case SSH_SESSION_STATE_DH:
|
||||||
|
case SSH_SESSION_STATE_INITIAL_KEX:
|
||||||
|
case SSH_SESSION_STATE_KEXINIT_RECEIVED:
|
||||||
|
return 0;
|
||||||
|
default:
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
* @brief Flushes a channel (and its session) until the output buffer
|
* @brief Flushes a channel (and its session) until the output buffer
|
||||||
@@ -1264,7 +1278,12 @@ int channel_write_common(ssh_channel channel, const void *data,
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
if (ssh_waitsession_unblocked(session) == 0){
|
||||||
|
rc = ssh_handle_packets_termination(session, SSH_TIMEOUT_USER,
|
||||||
|
ssh_waitsession_unblocked, session);
|
||||||
|
if (rc == SSH_ERROR || !ssh_waitsession_unblocked(session))
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
while (len > 0) {
|
while (len > 0) {
|
||||||
if (channel->remote_window < len) {
|
if (channel->remote_window < len) {
|
||||||
ssh_log(session, SSH_LOG_PROTOCOL,
|
ssh_log(session, SSH_LOG_PROTOCOL,
|
||||||
|
Reference in New Issue
Block a user