kentpeacock / rpms / openssh

Forked from rpms/openssh 2 years ago
Clone
2054b7
diff -up openssh-8.0p1/channels.c.channel-limits openssh-8.0p1/channels.c
2054b7
--- openssh-8.0p1/channels.c.channel-limits	2021-03-16 12:17:58.905576511 +0100
2054b7
+++ openssh-8.0p1/channels.c	2021-03-16 12:17:58.925576667 +0100
2054b7
@@ -354,6 +354,7 @@ channel_new(struct ssh *ssh, char *ctype
2054b7
 	struct ssh_channels *sc = ssh->chanctxt;
2054b7
 	u_int i, found;
2054b7
 	Channel *c;
2054b7
+	int r;
2054b7
 
2054b7
 	/* Try to find a free slot where to put the new channel. */
2054b7
 	for (i = 0; i < sc->channels_alloc; i++) {
2054b7
@@ -383,6 +384,8 @@ channel_new(struct ssh *ssh, char *ctype
2054b7
 	    (c->output = sshbuf_new()) == NULL ||
2054b7
 	    (c->extended = sshbuf_new()) == NULL)
2054b7
 		fatal("%s: sshbuf_new failed", __func__);
2054b7
+	if ((r = sshbuf_set_max_size(c->input, CHAN_INPUT_MAX)) != 0)
2054b7
+		fatal("%s: sshbuf_set_max_size: %s", __func__, ssh_err(r));
2054b7
 	c->ostate = CHAN_OUTPUT_OPEN;
2054b7
 	c->istate = CHAN_INPUT_OPEN;
2054b7
 	channel_register_fds(ssh, c, rfd, wfd, efd, extusage, nonblock, 0);
2054b7
diff -up openssh-8.0p1/channels.h.channel-limits openssh-8.0p1/channels.h
2054b7
--- openssh-8.0p1/channels.h.channel-limits	2021-03-16 12:17:58.868576223 +0100
2054b7
+++ openssh-8.0p1/channels.h	2021-03-16 12:17:58.907576527 +0100
2054b7
@@ -215,6 +215,9 @@ struct Channel {
2054b7
 /* Read buffer size */
2054b7
 #define CHAN_RBUF	(16*1024)
2054b7
 
2054b7
+/* Maximum channel input buffer size */
2054b7
+#define CHAN_INPUT_MAX	(16*1024*1024)
2054b7
+
2054b7
 /* Hard limit on number of channels */
2054b7
 #define CHANNELS_MAX_CHANNELS	(16*1024)
2054b7