1
1

channels: Fix ssh_channel_from_local()

It only worked if the first channel in the list was equivalent to we
were looking for.
Этот коммит содержится в:
rofl0r 2011-08-06 10:31:27 +02:00 коммит произвёл Andreas Schneider
родитель c31cac93f3
Коммит 39f962c91e

Просмотреть файл

@ -304,24 +304,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;
} }
/** /**