comparison common-session.c @ 910:89555751c489 asm

merge up to 2013.63, improve ASM makefile rules a bit
author Matt Johnston <matt@ucc.asn.au>
date Thu, 27 Feb 2014 21:35:58 +0800
parents a1a97e98b0c1
children bae0b34bc059 b8208506322e
comparison
equal deleted inserted replaced
909:e4b75744acab 910:89555751c489
28 #include "packet.h" 28 #include "packet.h"
29 #include "algo.h" 29 #include "algo.h"
30 #include "buffer.h" 30 #include "buffer.h"
31 #include "dss.h" 31 #include "dss.h"
32 #include "ssh.h" 32 #include "ssh.h"
33 #include "random.h" 33 #include "dbrandom.h"
34 #include "kex.h" 34 #include "kex.h"
35 #include "channel.h" 35 #include "channel.h"
36 #include "runopts.h" 36 #include "runopts.h"
37 37
38 static void checktimeouts(); 38 static void checktimeouts();
80 ses.payload = NULL; 80 ses.payload = NULL;
81 ses.recvseq = 0; 81 ses.recvseq = 0;
82 82
83 initqueue(&ses.writequeue); 83 initqueue(&ses.writequeue);
84 84
85 ses.requirenext[0] = SSH_MSG_KEXINIT; 85 ses.requirenext = SSH_MSG_KEXINIT;
86 ses.dataallowed = 1; /* we can send data until we actually 86 ses.dataallowed = 1; /* we can send data until we actually
87 send the SSH_MSG_KEXINIT */ 87 send the SSH_MSG_KEXINIT */
88 ses.ignorenext = 0; 88 ses.ignorenext = 0;
89 ses.lastpacket = 0; 89 ses.lastpacket = 0;
90 ses.reply_queue_head = NULL; 90 ses.reply_queue_head = NULL;
99 ses.keys->trans.crypt_mode = &dropbear_mode_none; 99 ses.keys->trans.crypt_mode = &dropbear_mode_none;
100 100
101 ses.keys->recv.algo_mac = &dropbear_nohash; 101 ses.keys->recv.algo_mac = &dropbear_nohash;
102 ses.keys->trans.algo_mac = &dropbear_nohash; 102 ses.keys->trans.algo_mac = &dropbear_nohash;
103 103
104 ses.keys->algo_kex = -1; 104 ses.keys->algo_kex = NULL;
105 ses.keys->algo_hostkey = -1; 105 ses.keys->algo_hostkey = -1;
106 ses.keys->recv.algo_comp = DROPBEAR_COMP_NONE; 106 ses.keys->recv.algo_comp = DROPBEAR_COMP_NONE;
107 ses.keys->trans.algo_comp = DROPBEAR_COMP_NONE; 107 ses.keys->trans.algo_comp = DROPBEAR_COMP_NONE;
108 108
109 #ifndef DISABLE_ZLIB 109 #ifndef DISABLE_ZLIB
151 151
152 /* We get woken up when signal handlers write to this pipe. 152 /* We get woken up when signal handlers write to this pipe.
153 SIGCHLD in svr-chansession is the only one currently. */ 153 SIGCHLD in svr-chansession is the only one currently. */
154 FD_SET(ses.signal_pipe[0], &readfd); 154 FD_SET(ses.signal_pipe[0], &readfd);
155 155
156 /* set up for channels which require reading/writing */ 156 /* set up for channels which can be read/written */
157 if (ses.dataallowed) { 157 setchannelfds(&readfd, &writefd);
158 setchannelfds(&readfd, &writefd); 158
159 }
160 val = select(ses.maxfd+1, &readfd, &writefd, NULL, &timeout); 159 val = select(ses.maxfd+1, &readfd, &writefd, NULL, &timeout);
161 160
162 if (exitflag) { 161 if (exitflag) {
163 dropbear_exit("Terminated by signal"); 162 dropbear_exit("Terminated by signal");
164 } 163 }
215 were being held up during a KEX */ 214 were being held up during a KEX */
216 maybe_flush_reply_queue(); 215 maybe_flush_reply_queue();
217 216
218 /* process pipes etc for the channels, ses.dataallowed == 0 217 /* process pipes etc for the channels, ses.dataallowed == 0
219 * during rekeying ) */ 218 * during rekeying ) */
220 if (ses.dataallowed) { 219 channelio(&readfd, &writefd);
221 channelio(&readfd, &writefd);
222 }
223 220
224 if (loophandler) { 221 if (loophandler) {
225 loophandler(); 222 loophandler();
226 } 223 }
227 224
242 } 239 }
243 240
244 if (ses.extra_session_cleanup) { 241 if (ses.extra_session_cleanup) {
245 ses.extra_session_cleanup(); 242 ses.extra_session_cleanup();
246 } 243 }
247 244
248 m_free(ses.session_id); 245 chancleanup();
246
247 /* Cleaning up keys must happen after other cleanup
248 functions which might queue packets */
249 if (ses.session_id) {
250 buf_burn(ses.session_id);
251 buf_free(ses.session_id);
252 ses.session_id = NULL;
253 }
254 if (ses.hash) {
255 buf_burn(ses.hash);
256 buf_free(ses.hash);
257 ses.hash = NULL;
258 }
249 m_burn(ses.keys, sizeof(struct key_context)); 259 m_burn(ses.keys, sizeof(struct key_context));
250 m_free(ses.keys); 260 m_free(ses.keys);
251
252 chancleanup();
253 261
254 TRACE(("leave session_cleanup")) 262 TRACE(("leave session_cleanup"))
255 } 263 }
256 264
257 void send_session_identification() { 265 void send_session_identification() {
258 buffer *writebuf = buf_new(strlen(LOCAL_IDENT "\r\n") + 1); 266 buffer *writebuf = buf_new(strlen(LOCAL_IDENT "\r\n") + 1);
259 buf_putbytes(writebuf, LOCAL_IDENT "\r\n", strlen(LOCAL_IDENT "\r\n")); 267 buf_putbytes(writebuf, LOCAL_IDENT "\r\n", strlen(LOCAL_IDENT "\r\n"));
260 buf_putbyte(writebuf, 0x0); // packet type 268 buf_putbyte(writebuf, 0x0); /* packet type */
261 buf_setpos(writebuf, 0); 269 buf_setpos(writebuf, 0);
262 enqueue(&ses.writequeue, writebuf); 270 enqueue(&ses.writequeue, writebuf);
263 } 271 }
264 272
265 static void read_session_identification() { 273 static void read_session_identification() {