comparison common-session.c @ 452:4cab61369879

Prevent invalid packets being sent during key-exchange, instead queue them until afterwards. This could sometimes terminate connections after 8 hours if (for example) a new TCP forwarded connection was sent at the KEX timeout.
author Matt Johnston <matt@ucc.asn.au>
date Fri, 27 Jul 2007 17:13:42 +0000
parents 9c61e7af0156
children 7e43f5e473b9
comparison
equal deleted inserted replaced
451:f2aa5aeea619 452:4cab61369879
78 ses.recvseq = 0; 78 ses.recvseq = 0;
79 79
80 initqueue(&ses.writequeue); 80 initqueue(&ses.writequeue);
81 81
82 ses.requirenext = SSH_MSG_KEXINIT; 82 ses.requirenext = SSH_MSG_KEXINIT;
83 ses.dataallowed = 0; /* don't send data yet, we'll wait until after kex */ 83 ses.dataallowed = 1; /* we can send data until we actually
84 send the SSH_MSG_KEXINIT */
84 ses.ignorenext = 0; 85 ses.ignorenext = 0;
85 ses.lastpacket = 0; 86 ses.lastpacket = 0;
87 ses.reply_queue_head = NULL;
88 ses.reply_queue_tail = NULL;
86 89
87 /* set all the algos to none */ 90 /* set all the algos to none */
88 ses.keys = (struct key_context*)m_malloc(sizeof(struct key_context)); 91 ses.keys = (struct key_context*)m_malloc(sizeof(struct key_context));
89 ses.newkeys = NULL; 92 ses.newkeys = NULL;
90 ses.keys->recv_algo_crypt = &dropbear_nocipher; 93 ses.keys->recv_algo_crypt = &dropbear_nocipher;
190 * will be ready for a new packet */ 193 * will be ready for a new packet */
191 if (ses.payload != NULL) { 194 if (ses.payload != NULL) {
192 process_packet(); 195 process_packet();
193 } 196 }
194 } 197 }
198
199 /* if required, flush out any queued reply packets that
200 were being held up during a KEX */
201 maybe_flush_reply_queue();
195 202
196 /* process pipes etc for the channels, ses.dataallowed == 0 203 /* process pipes etc for the channels, ses.dataallowed == 0
197 * during rekeying ) */ 204 * during rekeying ) */
198 if (ses.dataallowed) { 205 if (ses.dataallowed) {
199 channelio(&readfd, &writefd); 206 channelio(&readfd, &writefd);