diff options
author | rofl0r <retnyg@gmx.net> | 2011-08-06 10:31:27 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2011-08-07 12:46:06 +0200 |
commit | fb8f2cd11b938f0b1fe660df7630c0eee47b27ff (patch) | |
tree | 3ac95767dc2b6288d3512d3c5b13eac61453c503 /src/channels.c | |
parent | 1d8a9ddf84071eae0cfb761b5cde49d2e429819d (diff) | |
download | libssh-fb8f2cd11b938f0b1fe660df7630c0eee47b27ff.tar.gz libssh-fb8f2cd11b938f0b1fe660df7630c0eee47b27ff.tar.xz libssh-fb8f2cd11b938f0b1fe660df7630c0eee47b27ff.zip |
channels: Fix ssh_channel_from_local()
It only worked if the first channel in the list was equivalent to we
were looking for.
(cherry picked from commit 39f962c91eb4575a65edc7d984ce3f1a699097b8)
Diffstat (limited to 'src/channels.c')
-rw-r--r-- | src/channels.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/channels.c b/src/channels.c index aebf68d4..f0eb9ef8 100644 --- a/src/channels.c +++ b/src/channels.c @@ -300,24 +300,25 @@ static int channel_open(ssh_channel channel, const char *type_c, int window, return err; } -/* get ssh channel from local session? */ +/* return channel with corresponding local id, or NULL if not found */ ssh_channel ssh_channel_from_local(ssh_session session, uint32_t id) { - ssh_channel initchan = session->channels; - ssh_channel channel; + ssh_channel initchan = session->channels; + ssh_channel channel = initchan; - /* We assume we are always the local */ - if (initchan == NULL) { - return NULL; - } - - for (channel = initchan; channel->local_channel != id; - channel=channel->next) { - if (channel->next == initchan) { - return NULL; + for (;;) { + if (channel == NULL) { + return NULL; + } + if (channel->local_channel == id) { + return channel; + } + if (channel->next == initchan) { + return NULL; + } + channel = channel->next; } - } - return channel; + return NULL; } /** |