comparison 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
comparison
equal deleted inserted replaced
905:f98618496f82 906:4696755c4cac
57 #define FD_CLOSED (-1) 57 #define FD_CLOSED (-1)
58 58
59 #define ERRFD_IS_READ(channel) ((channel)->extrabuf == NULL) 59 #define ERRFD_IS_READ(channel) ((channel)->extrabuf == NULL)
60 #define ERRFD_IS_WRITE(channel) (!ERRFD_IS_READ(channel)) 60 #define ERRFD_IS_WRITE(channel) (!ERRFD_IS_READ(channel))
61 61
62 /* allow space for:
63 * 1 byte byte SSH_MSG_CHANNEL_DATA
64 * 4 bytes uint32 recipient channel
65 * 4 bytes string data
66 */
67 #define RECV_MAX_CHANNEL_DATA_LEN (RECV_MAX_PAYLOAD_LEN-(1+4+4))
68
62 /* Initialise all the channels */ 69 /* Initialise all the channels */
63 void chaninitialise(const struct ChanType *chantypes[]) { 70 void chaninitialise(const struct ChanType *chantypes[]) {
64 71
65 /* may as well create space for a single channel */ 72 /* may as well create space for a single channel */
66 ses.channels = (struct Channel**)m_malloc(sizeof(struct Channel*)); 73 ses.channels = (struct Channel**)m_malloc(sizeof(struct Channel*));
163 newchan->writebuf = cbuf_new(0); /* resized later by chan_initwritebuf */ 170 newchan->writebuf = cbuf_new(0); /* resized later by chan_initwritebuf */
164 newchan->recvwindow = 0; 171 newchan->recvwindow = 0;
165 172
166 newchan->extrabuf = NULL; /* The user code can set it up */ 173 newchan->extrabuf = NULL; /* The user code can set it up */
167 newchan->recvdonelen = 0; 174 newchan->recvdonelen = 0;
168 newchan->recvmaxpacket = RECV_MAX_PAYLOAD_LEN; 175 newchan->recvmaxpacket = RECV_MAX_CHANNEL_DATA_LEN;
169 176
170 ses.channels[i] = newchan; 177 ses.channels[i] = newchan;
171 ses.chancount++; 178 ses.chancount++;
172 179
173 TRACE(("leave newchannel")) 180 TRACE(("leave newchannel"))
1026 1033
1027 buf_putbyte(ses.writepayload, SSH_MSG_CHANNEL_OPEN); 1034 buf_putbyte(ses.writepayload, SSH_MSG_CHANNEL_OPEN);
1028 buf_putstring(ses.writepayload, type->name, strlen(type->name)); 1035 buf_putstring(ses.writepayload, type->name, strlen(type->name));
1029 buf_putint(ses.writepayload, chan->index); 1036 buf_putint(ses.writepayload, chan->index);
1030 buf_putint(ses.writepayload, opts.recv_window); 1037 buf_putint(ses.writepayload, opts.recv_window);
1031 buf_putint(ses.writepayload, RECV_MAX_PAYLOAD_LEN); 1038 buf_putint(ses.writepayload, RECV_MAX_CHANNEL_DATA_LEN);
1032 1039
1033 TRACE(("leave send_msg_channel_open_init()")) 1040 TRACE(("leave send_msg_channel_open_init()"))
1034 return DROPBEAR_SUCCESS; 1041 return DROPBEAR_SUCCESS;
1035 } 1042 }
1036 1043