mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-11 10:40:27 +09:00
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 39f962c91e)
This commit is contained in:
committed by
Andreas Schneider
parent
1d8a9ddf84
commit
fb8f2cd11b
@@ -300,24 +300,25 @@ static int channel_open(ssh_channel channel, const char *type_c, int window,
|
|||||||
return err;
|
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 ssh_channel_from_local(ssh_session session, uint32_t id) {
|
||||||
ssh_channel initchan = session->channels;
|
ssh_channel initchan = session->channels;
|
||||||
ssh_channel channel;
|
ssh_channel channel = initchan;
|
||||||
|
|
||||||
/* We assume we are always the local */
|
for (;;) {
|
||||||
if (initchan == NULL) {
|
if (channel == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
if (channel->local_channel == id) {
|
||||||
for (channel = initchan; channel->local_channel != id;
|
return channel;
|
||||||
channel=channel->next) {
|
}
|
||||||
if (channel->next == initchan) {
|
if (channel->next == initchan) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
channel = channel->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
return channel;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user