client: Reset session packet state on disconnect

When reusing session structures for multiple
connections, the packet state could be SIZE_READ
before disconnect, causing initial packets of the
next connection to be misinterpreted.

Signed-off-by: Pavol Žáčik <pzacik@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
(cherry picked from commit 41b8b3326c)
This commit is contained in:
Pavol Žáčik
2025-10-21 15:34:53 +02:00
committed by Jakub Jelen
parent 274b8f19b3
commit c206e5d84e

View File

@@ -836,6 +836,7 @@ error:
session->opts.fd = SSH_INVALID_SOCKET; session->opts.fd = SSH_INVALID_SOCKET;
session->session_state = SSH_SESSION_STATE_DISCONNECTED; session->session_state = SSH_SESSION_STATE_DISCONNECTED;
session->pending_call_state = SSH_PENDING_CALL_NONE; session->pending_call_state = SSH_PENDING_CALL_NONE;
session->packet_state = PACKET_STATE_INIT;
while ((it = ssh_list_get_iterator(session->channels)) != NULL) { while ((it = ssh_list_get_iterator(session->channels)) != NULL) {
ssh_channel_do_free(ssh_iterator_value(ssh_channel, it)); ssh_channel_do_free(ssh_iterator_value(ssh_channel, it));