diff options
author | 2005-12-12 13:46:18 +0000 | |
---|---|---|
committer | 2005-12-12 13:46:18 +0000 | |
commit | 27f4c291c946b3530b69fb48dc8298bf0b007589 (patch) | |
tree | 2cafb9181a313a1477e6b2de0f9695a541b7b0e2 /usr.bin/ssh/channels.c | |
parent | Drop clause 3/4 as per i386 version this was based on. (diff) | |
download | wireguard-openbsd-27f4c291c946b3530b69fb48dc8298bf0b007589.tar.xz wireguard-openbsd-27f4c291c946b3530b69fb48dc8298bf0b007589.zip |
make sure protocol messages for internal channels are ignored.
allow adjust messages for non-open channels; with and ok djm@
Diffstat (limited to 'usr.bin/ssh/channels.c')
-rw-r--r-- | usr.bin/ssh/channels.c | 45 |
1 files changed, 36 insertions, 9 deletions
diff --git a/usr.bin/ssh/channels.c b/usr.bin/ssh/channels.c index b494ba73279..ac5a4a99244 100644 --- a/usr.bin/ssh/channels.c +++ b/usr.bin/ssh/channels.c @@ -39,7 +39,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: channels.c,v 1.228 2005/12/06 22:38:27 reyk Exp $"); +RCSID("$OpenBSD: channels.c,v 1.229 2005/12/12 13:46:18 markus Exp $"); #include "ssh.h" #include "ssh1.h" @@ -142,23 +142,51 @@ static void port_open_helper(Channel *c, char *rtype); /* -- channel core */ Channel * -channel_lookup(int id) +channel_by_id(int id) { Channel *c; if (id < 0 || (u_int)id >= channels_alloc) { - logit("channel_lookup: %d: bad id", id); + logit("channel_by_id: %d: bad id", id); return NULL; } c = channels[id]; if (c == NULL) { - logit("channel_lookup: %d: bad id: channel free", id); + logit("channel_by_id: %d: bad id: channel free", id); return NULL; } return c; } /* + * Returns the channel if it is allowed to receive protocol messages. + * Private channels, like listening sockets, may not receive messages. + */ +Channel * +channel_lookup(int id) +{ + Channel *c; + + if ((c = channel_by_id(id)) == NULL) + return (NULL); + + switch(c->type) { + case SSH_CHANNEL_X11_OPEN: + case SSH_CHANNEL_LARVAL: + case SSH_CHANNEL_CONNECTING: + case SSH_CHANNEL_DYNAMIC: + case SSH_CHANNEL_OPENING: + case SSH_CHANNEL_OPEN: + case SSH_CHANNEL_INPUT_DRAINING: + case SSH_CHANNEL_OUTPUT_DRAINING: + return (c); + break; + } + logit("Non-public channel %d, type %d.", id, c->type); + return (NULL); +} + +/* * Register filedescriptors for a channel, used when allocating a channel or * when the channel consumer/producer is ready, e.g. shell exec'd */ @@ -630,7 +658,7 @@ channel_register_confirm(int id, channel_callback_fn *fn, void *ctx) void channel_register_cleanup(int id, channel_callback_fn *fn, int do_close) { - Channel *c = channel_lookup(id); + Channel *c = channel_by_id(id); if (c == NULL) { logit("channel_register_cleanup: %d: bad id", id); @@ -642,7 +670,7 @@ channel_register_cleanup(int id, channel_callback_fn *fn, int do_close) void channel_cancel_cleanup(int id) { - Channel *c = channel_lookup(id); + Channel *c = channel_by_id(id); if (c == NULL) { logit("channel_cancel_cleanup: %d: bad id", id); @@ -2177,9 +2205,8 @@ channel_input_window_adjust(int type, u_int32_t seq, void *ctxt) id = packet_get_int(); c = channel_lookup(id); - if (c == NULL || c->type != SSH_CHANNEL_OPEN) { - logit("Received window adjust for " - "non-open channel %d.", id); + if (c == NULL) { + logit("Received window adjust for non-open channel %d.", id); return; } adjust = packet_get_int(); |