diff common-channel.c @ 906:4696755c4cac

A few fixes for cases where compression increases payload sizes, and be more precise about maximum channel sizes
author Matt Johnston <matt@ucc.asn.au>
date Sat, 22 Feb 2014 18:02:09 +0800
parents a1a97e98b0c1
children d93a6bcf616f
line wrap: on
line diff
--- a/common-channel.c	Wed Feb 19 22:18:11 2014 +0800
+++ b/common-channel.c	Sat Feb 22 18:02:09 2014 +0800
@@ -59,6 +59,13 @@
 #define ERRFD_IS_READ(channel) ((channel)->extrabuf == NULL)
 #define ERRFD_IS_WRITE(channel) (!ERRFD_IS_READ(channel))
 
+/* allow space for:
+ * 1 byte  byte      SSH_MSG_CHANNEL_DATA
+ * 4 bytes uint32    recipient channel
+ * 4 bytes string    data
+ */
+#define RECV_MAX_CHANNEL_DATA_LEN (RECV_MAX_PAYLOAD_LEN-(1+4+4))
+
 /* Initialise all the channels */
 void chaninitialise(const struct ChanType *chantypes[]) {
 
@@ -165,7 +172,7 @@
 
 	newchan->extrabuf = NULL; /* The user code can set it up */
 	newchan->recvdonelen = 0;
-	newchan->recvmaxpacket = RECV_MAX_PAYLOAD_LEN;
+	newchan->recvmaxpacket = RECV_MAX_CHANNEL_DATA_LEN;
 
 	ses.channels[i] = newchan;
 	ses.chancount++;
@@ -1028,7 +1035,7 @@
 	buf_putstring(ses.writepayload, type->name, strlen(type->name));
 	buf_putint(ses.writepayload, chan->index);
 	buf_putint(ses.writepayload, opts.recv_window);
-	buf_putint(ses.writepayload, RECV_MAX_PAYLOAD_LEN);
+	buf_putint(ses.writepayload, RECV_MAX_CHANNEL_DATA_LEN);
 
 	TRACE(("leave send_msg_channel_open_init()"))
 	return DROPBEAR_SUCCESS;