diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | channels.c | 45 | ||||
-rw-r--r-- | channels.h | 3 | ||||
-rw-r--r-- | session.c | 4 |
4 files changed, 45 insertions, 13 deletions
@@ -51,6 +51,10 @@ | |||
51 | - jmc@cvs.openbsd.org 2005/12/08 21:37:50 | 51 | - jmc@cvs.openbsd.org 2005/12/08 21:37:50 |
52 | [ssh_config.5] | 52 | [ssh_config.5] |
53 | new sentence, new line; | 53 | new sentence, new line; |
54 | - markus@cvs.openbsd.org 2005/12/12 13:46:18 | ||
55 | [channels.c channels.h session.c] | ||
56 | make sure protocol messages for internal channels are ignored. | ||
57 | allow adjust messages for non-open channels; with and ok djm@ | ||
54 | 58 | ||
55 | 20051201 | 59 | 20051201 |
56 | - (djm) [envpass.sh] Remove regress script that was accidentally committed | 60 | - (djm) [envpass.sh] Remove regress script that was accidentally committed |
@@ -3443,4 +3447,4 @@ | |||
3443 | - (djm) Trim deprecated options from INSTALL. Mention UsePAM | 3447 | - (djm) Trim deprecated options from INSTALL. Mention UsePAM |
3444 | - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu | 3448 | - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu |
3445 | 3449 | ||
3446 | $Id: ChangeLog,v 1.4025 2005/12/13 08:33:37 djm Exp $ | 3450 | $Id: ChangeLog,v 1.4026 2005/12/13 08:33:57 djm Exp $ |
diff --git a/channels.c b/channels.c index b4fd89f96..e73dc247d 100644 --- a/channels.c +++ b/channels.c | |||
@@ -39,7 +39,7 @@ | |||
39 | */ | 39 | */ |
40 | 40 | ||
41 | #include "includes.h" | 41 | #include "includes.h" |
42 | RCSID("$OpenBSD: channels.c,v 1.228 2005/12/06 22:38:27 reyk Exp $"); | 42 | RCSID("$OpenBSD: channels.c,v 1.229 2005/12/12 13:46:18 markus Exp $"); |
43 | 43 | ||
44 | #include "ssh.h" | 44 | #include "ssh.h" |
45 | #include "ssh1.h" | 45 | #include "ssh1.h" |
@@ -142,23 +142,51 @@ static void port_open_helper(Channel *c, char *rtype); | |||
142 | /* -- channel core */ | 142 | /* -- channel core */ |
143 | 143 | ||
144 | Channel * | 144 | Channel * |
145 | channel_lookup(int id) | 145 | channel_by_id(int id) |
146 | { | 146 | { |
147 | Channel *c; | 147 | Channel *c; |
148 | 148 | ||
149 | if (id < 0 || (u_int)id >= channels_alloc) { | 149 | if (id < 0 || (u_int)id >= channels_alloc) { |
150 | logit("channel_lookup: %d: bad id", id); | 150 | logit("channel_by_id: %d: bad id", id); |
151 | return NULL; | 151 | return NULL; |
152 | } | 152 | } |
153 | c = channels[id]; | 153 | c = channels[id]; |
154 | if (c == NULL) { | 154 | if (c == NULL) { |
155 | logit("channel_lookup: %d: bad id: channel free", id); | 155 | logit("channel_by_id: %d: bad id: channel free", id); |
156 | return NULL; | 156 | return NULL; |
157 | } | 157 | } |
158 | return c; | 158 | return c; |
159 | } | 159 | } |
160 | 160 | ||
161 | /* | 161 | /* |
162 | * Returns the channel if it is allowed to receive protocol messages. | ||
163 | * Private channels, like listening sockets, may not receive messages. | ||
164 | */ | ||
165 | Channel * | ||
166 | channel_lookup(int id) | ||
167 | { | ||
168 | Channel *c; | ||
169 | |||
170 | if ((c = channel_by_id(id)) == NULL) | ||
171 | return (NULL); | ||
172 | |||
173 | switch(c->type) { | ||
174 | case SSH_CHANNEL_X11_OPEN: | ||
175 | case SSH_CHANNEL_LARVAL: | ||
176 | case SSH_CHANNEL_CONNECTING: | ||
177 | case SSH_CHANNEL_DYNAMIC: | ||
178 | case SSH_CHANNEL_OPENING: | ||
179 | case SSH_CHANNEL_OPEN: | ||
180 | case SSH_CHANNEL_INPUT_DRAINING: | ||
181 | case SSH_CHANNEL_OUTPUT_DRAINING: | ||
182 | return (c); | ||
183 | break; | ||
184 | } | ||
185 | logit("Non-public channel %d, type %d.", id, c->type); | ||
186 | return (NULL); | ||
187 | } | ||
188 | |||
189 | /* | ||
162 | * Register filedescriptors for a channel, used when allocating a channel or | 190 | * Register filedescriptors for a channel, used when allocating a channel or |
163 | * when the channel consumer/producer is ready, e.g. shell exec'd | 191 | * when the channel consumer/producer is ready, e.g. shell exec'd |
164 | */ | 192 | */ |
@@ -631,7 +659,7 @@ channel_register_confirm(int id, channel_callback_fn *fn, void *ctx) | |||
631 | void | 659 | void |
632 | channel_register_cleanup(int id, channel_callback_fn *fn, int do_close) | 660 | channel_register_cleanup(int id, channel_callback_fn *fn, int do_close) |
633 | { | 661 | { |
634 | Channel *c = channel_lookup(id); | 662 | Channel *c = channel_by_id(id); |
635 | 663 | ||
636 | if (c == NULL) { | 664 | if (c == NULL) { |
637 | logit("channel_register_cleanup: %d: bad id", id); | 665 | logit("channel_register_cleanup: %d: bad id", id); |
@@ -643,7 +671,7 @@ channel_register_cleanup(int id, channel_callback_fn *fn, int do_close) | |||
643 | void | 671 | void |
644 | channel_cancel_cleanup(int id) | 672 | channel_cancel_cleanup(int id) |
645 | { | 673 | { |
646 | Channel *c = channel_lookup(id); | 674 | Channel *c = channel_by_id(id); |
647 | 675 | ||
648 | if (c == NULL) { | 676 | if (c == NULL) { |
649 | logit("channel_cancel_cleanup: %d: bad id", id); | 677 | logit("channel_cancel_cleanup: %d: bad id", id); |
@@ -2183,9 +2211,8 @@ channel_input_window_adjust(int type, u_int32_t seq, void *ctxt) | |||
2183 | id = packet_get_int(); | 2211 | id = packet_get_int(); |
2184 | c = channel_lookup(id); | 2212 | c = channel_lookup(id); |
2185 | 2213 | ||
2186 | if (c == NULL || c->type != SSH_CHANNEL_OPEN) { | 2214 | if (c == NULL) { |
2187 | logit("Received window adjust for " | 2215 | logit("Received window adjust for non-open channel %d.", id); |
2188 | "non-open channel %d.", id); | ||
2189 | return; | 2216 | return; |
2190 | } | 2217 | } |
2191 | adjust = packet_get_int(); | 2218 | adjust = packet_get_int(); |
diff --git a/channels.h b/channels.h index 743a2065e..7990fe147 100644 --- a/channels.h +++ b/channels.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: channels.h,v 1.81 2005/12/06 22:38:27 reyk Exp $ */ | 1 | /* $OpenBSD: channels.h,v 1.82 2005/12/12 13:46:18 markus Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
@@ -157,6 +157,7 @@ struct Channel { | |||
157 | 157 | ||
158 | /* channel management */ | 158 | /* channel management */ |
159 | 159 | ||
160 | Channel *channel_by_id(int); | ||
160 | Channel *channel_lookup(int); | 161 | Channel *channel_lookup(int); |
161 | Channel *channel_new(char *, int, int, int, int, u_int, u_int, int, char *, int); | 162 | Channel *channel_new(char *, int, int, int, int, u_int, u_int, int, char *, int); |
162 | void channel_set_fds(int, int, int, int, int, int, u_int); | 163 | void channel_set_fds(int, int, int, int, int, int, u_int); |
@@ -33,7 +33,7 @@ | |||
33 | */ | 33 | */ |
34 | 34 | ||
35 | #include "includes.h" | 35 | #include "includes.h" |
36 | RCSID("$OpenBSD: session.c,v 1.188 2005/10/30 08:52:17 djm Exp $"); | 36 | RCSID("$OpenBSD: session.c,v 1.189 2005/12/12 13:46:18 markus Exp $"); |
37 | 37 | ||
38 | #include "ssh.h" | 38 | #include "ssh.h" |
39 | #include "ssh1.h" | 39 | #include "ssh1.h" |
@@ -2101,7 +2101,7 @@ session_close_x11(int id) | |||
2101 | { | 2101 | { |
2102 | Channel *c; | 2102 | Channel *c; |
2103 | 2103 | ||
2104 | if ((c = channel_lookup(id)) == NULL) { | 2104 | if ((c = channel_by_id(id)) == NULL) { |
2105 | debug("session_close_x11: x11 channel %d missing", id); | 2105 | debug("session_close_x11: x11 channel %d missing", id); |
2106 | } else { | 2106 | } else { |
2107 | /* Detach X11 listener */ | 2107 | /* Detach X11 listener */ |