From d222ed4251d5ffed8fa05998c0f47ae2abafaa6e Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Tue, 6 Nov 2018 18:31:35 +0000 Subject: [PATCH] Fix a segfault in ssh2_throttle_all_channels. ssh2_channel_check_throttle should only be called on channels for which c->chan != NULL - that is, only for channels that are not delegated to a sharing downstream. But throttle_all_channels was calling it for _all_ channels, so if it had the bad luck to be called while a sharing downstream was active, ssh2_channel_check_throttle would dereference the null c->chan for the first downstream channel it found. --- ssh2connection.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ssh2connection.c b/ssh2connection.c index f1135309..f9f40a9b 100644 --- a/ssh2connection.c +++ b/ssh2connection.c @@ -1611,7 +1611,8 @@ static void ssh2_throttle_all_channels(ConnectionLayer *cl, bool throttled) s->all_channels_throttled = throttled; for (i = 0; NULL != (c = index234(s->channels, i)); i++) - ssh2_channel_check_throttle(c); + if (!c->sharectx) + ssh2_channel_check_throttle(c); } static bool ssh2_ldisc_option(ConnectionLayer *cl, int option)