diff options
Diffstat (limited to 'channels.c')
-rw-r--r-- | channels.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/channels.c b/channels.c index 2dea5dfd0..b8507ca13 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.212 2005/03/01 10:09:52 djm Exp $"); | 42 | RCSID("$OpenBSD: channels.c,v 1.214 2005/03/14 11:46:56 markus Exp $"); |
43 | 43 | ||
44 | #include "ssh.h" | 44 | #include "ssh.h" |
45 | #include "ssh1.h" | 45 | #include "ssh1.h" |
@@ -58,6 +58,8 @@ RCSID("$OpenBSD: channels.c,v 1.212 2005/03/01 10:09:52 djm Exp $"); | |||
58 | 58 | ||
59 | /* -- channel core */ | 59 | /* -- channel core */ |
60 | 60 | ||
61 | #define CHAN_RBUF 16*1024 | ||
62 | |||
61 | /* | 63 | /* |
62 | * Pointer to an array containing all allocated channels. The array is | 64 | * Pointer to an array containing all allocated channels. The array is |
63 | * dynamically extended as needed. | 65 | * dynamically extended as needed. |
@@ -712,6 +714,9 @@ channel_pre_open(Channel *c, fd_set * readset, fd_set * writeset) | |||
712 | { | 714 | { |
713 | u_int limit = compat20 ? c->remote_window : packet_get_maxsize(); | 715 | u_int limit = compat20 ? c->remote_window : packet_get_maxsize(); |
714 | 716 | ||
717 | /* check buffer limits */ | ||
718 | limit = MIN(limit, (BUFFER_MAX_LEN - BUFFER_MAX_CHUNK - CHAN_RBUF)); | ||
719 | |||
715 | if (c->istate == CHAN_INPUT_OPEN && | 720 | if (c->istate == CHAN_INPUT_OPEN && |
716 | limit > 0 && | 721 | limit > 0 && |
717 | buffer_len(&c->input) < limit) | 722 | buffer_len(&c->input) < limit) |
@@ -1018,7 +1023,7 @@ channel_decode_socks5(Channel *c, fd_set * readset, fd_set * writeset) | |||
1018 | debug2("channel %d: only socks5 connect supported", c->self); | 1023 | debug2("channel %d: only socks5 connect supported", c->self); |
1019 | return -1; | 1024 | return -1; |
1020 | } | 1025 | } |
1021 | switch(s5_req.atyp){ | 1026 | switch (s5_req.atyp){ |
1022 | case SSH_SOCKS5_IPV4: | 1027 | case SSH_SOCKS5_IPV4: |
1023 | addrlen = 4; | 1028 | addrlen = 4; |
1024 | af = AF_INET; | 1029 | af = AF_INET; |
@@ -1360,7 +1365,7 @@ channel_post_connecting(Channel *c, fd_set * readset, fd_set * writeset) | |||
1360 | static int | 1365 | static int |
1361 | channel_handle_rfd(Channel *c, fd_set * readset, fd_set * writeset) | 1366 | channel_handle_rfd(Channel *c, fd_set * readset, fd_set * writeset) |
1362 | { | 1367 | { |
1363 | char buf[16*1024]; | 1368 | char buf[CHAN_RBUF]; |
1364 | int len; | 1369 | int len; |
1365 | 1370 | ||
1366 | if (c->rfd != -1 && | 1371 | if (c->rfd != -1 && |
@@ -1454,7 +1459,7 @@ channel_handle_wfd(Channel *c, fd_set * readset, fd_set * writeset) | |||
1454 | static int | 1459 | static int |
1455 | channel_handle_efd(Channel *c, fd_set * readset, fd_set * writeset) | 1460 | channel_handle_efd(Channel *c, fd_set * readset, fd_set * writeset) |
1456 | { | 1461 | { |
1457 | char buf[16*1024]; | 1462 | char buf[CHAN_RBUF]; |
1458 | int len; | 1463 | int len; |
1459 | 1464 | ||
1460 | /** XXX handle drain efd, too */ | 1465 | /** XXX handle drain efd, too */ |
@@ -2199,11 +2204,11 @@ channel_setup_fwd_listener(int type, const char *listen_addr, u_short listen_por | |||
2199 | 2204 | ||
2200 | /* | 2205 | /* |
2201 | * Determine whether or not a port forward listens to loopback, | 2206 | * Determine whether or not a port forward listens to loopback, |
2202 | * specified address or wildcard. On the client, a specified bind | 2207 | * specified address or wildcard. On the client, a specified bind |
2203 | * address will always override gateway_ports. On the server, a | 2208 | * address will always override gateway_ports. On the server, a |
2204 | * gateway_ports of 1 (``yes'') will override the client's | 2209 | * gateway_ports of 1 (``yes'') will override the client's |
2205 | * specification and force a wildcard bind, whereas a value of 2 | 2210 | * specification and force a wildcard bind, whereas a value of 2 |
2206 | * (``clientspecified'') will bind to whatever address the client | 2211 | * (``clientspecified'') will bind to whatever address the client |
2207 | * asked for. | 2212 | * asked for. |
2208 | * | 2213 | * |
2209 | * Special-case listen_addrs are: | 2214 | * Special-case listen_addrs are: |
@@ -2317,7 +2322,7 @@ channel_cancel_rport_listener(const char *host, u_short port) | |||
2317 | u_int i; | 2322 | u_int i; |
2318 | int found = 0; | 2323 | int found = 0; |
2319 | 2324 | ||
2320 | for(i = 0; i < channels_alloc; i++) { | 2325 | for (i = 0; i < channels_alloc; i++) { |
2321 | Channel *c = channels[i]; | 2326 | Channel *c = channels[i]; |
2322 | 2327 | ||
2323 | if (c != NULL && c->type == SSH_CHANNEL_RPORT_LISTENER && | 2328 | if (c != NULL && c->type == SSH_CHANNEL_RPORT_LISTENER && |
@@ -2629,7 +2634,7 @@ channel_send_window_changes(void) | |||
2629 | struct winsize ws; | 2634 | struct winsize ws; |
2630 | 2635 | ||
2631 | for (i = 0; i < channels_alloc; i++) { | 2636 | for (i = 0; i < channels_alloc; i++) { |
2632 | if (channels[i] == NULL || !channels[i]->client_tty || | 2637 | if (channels[i] == NULL || !channels[i]->client_tty || |
2633 | channels[i]->type != SSH_CHANNEL_OPEN) | 2638 | channels[i]->type != SSH_CHANNEL_OPEN) |
2634 | continue; | 2639 | continue; |
2635 | if (ioctl(channels[i]->rfd, TIOCGWINSZ, &ws) < 0) | 2640 | if (ioctl(channels[i]->rfd, TIOCGWINSZ, &ws) < 0) |