summaryrefslogtreecommitdiff
path: root/channels.c
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2005-03-14 23:22:25 +1100
committerDarren Tucker <dtucker@zip.com.au>2005-03-14 23:22:25 +1100
commit11327cc5d7437b17f98580f1f173918873872c0d (patch)
tree791c8e0394d790059863e63bd8c4d35d9f593fe1 /channels.c
parenta8f553df53bf116c16de409a0d6bc897d0a2f228 (diff)
- markus@cvs.openbsd.org 2005/03/14 11:46:56
[buffer.c buffer.h channels.c] limit input buffer size for channels; bugzilla #896; with and ok dtucker@
Diffstat (limited to 'channels.c')
-rw-r--r--channels.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/channels.c b/channels.c
index 4bd9af8e6..3f6db60c6 100644
--- a/channels.c
+++ b/channels.c
@@ -39,7 +39,7 @@
39 */ 39 */
40 40
41#include "includes.h" 41#include "includes.h"
42RCSID("$OpenBSD: channels.c,v 1.213 2005/03/10 22:01:05 deraadt Exp $"); 42RCSID("$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.213 2005/03/10 22:01:05 deraadt 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)
@@ -1360,7 +1365,7 @@ channel_post_connecting(Channel *c, fd_set * readset, fd_set * writeset)
1360static int 1365static int
1361channel_handle_rfd(Channel *c, fd_set * readset, fd_set * writeset) 1366channel_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)
1454static int 1459static int
1455channel_handle_efd(Channel *c, fd_set * readset, fd_set * writeset) 1460channel_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 */