[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] client: use ssh_channel_do_free in ssh_disconnect


Hi,

Attached is a patch that ensures to fully free channels as they
are removed from the ssh_session channels list via ssh_disconnect.

Without this change, channels that are not gracefully closed can
be lost in the sequence: ssh_disconnect(S), ssh_free(S), because
ssh_disconnect removes the channels from the session's list.


-Jon
From 6d151c9b5e3a68a616b1ea010825278841970132 Mon Sep 17 00:00:00 2001
From: Jon Simons <jon@xxxxxxxxxxxxx>
Date: Mon, 9 Dec 2013 12:38:55 -0800
Subject: [PATCH] client: use ssh_channel_do_free in ssh_disconnect

Ensure to use 'ssh_channel_do_free' in 'ssh_disconnect', when removing and
free'ing up a session's channels.  This matches the behavior in 'ssh_free',
and is necessary to fully free any channel which may not have been closed
completely (see usage of flags SSH_CHANNEL_FLAG_CLOSED_REMOTE,
SSH_CHANNEL_FLAG_FREED_LOCAL).
---
 src/client.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/client.c b/src/client.c
index 35c396a..8951e8d 100644
--- a/src/client.c
+++ b/src/client.c
@@ -652,7 +652,7 @@ error:
   session->session_state=SSH_SESSION_STATE_DISCONNECTED;
 
   while ((it=ssh_list_get_iterator(session->channels)) != NULL) {
-    ssh_channel_free(ssh_iterator_value(ssh_channel,it));
+    ssh_channel_do_free(ssh_iterator_value(ssh_channel,it));
     ssh_list_remove(session->channels, it);
   }
   if(session->current_crypto){
-- 
1.8.4.21.g992c386


Follow-Ups:
Re: [PATCH] client: use ssh_channel_do_free in ssh_disconnectAndreas Schneider <asn@xxxxxxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org