comparison svr-session.c @ 1563:1cbb7b3d6703

Merge fuzzing branch
author Matt Johnston <matt@ucc.asn.au>
date Wed, 28 Feb 2018 22:12:05 +0800
parents 92c93b4a3646
children 76189c9ffea2
comparison
equal deleted inserted replaced
1560:f5026f7486de 1563:1cbb7b3d6703
38 #include "tcpfwd.h" 38 #include "tcpfwd.h"
39 #include "service.h" 39 #include "service.h"
40 #include "auth.h" 40 #include "auth.h"
41 #include "runopts.h" 41 #include "runopts.h"
42 #include "crypto_desc.h" 42 #include "crypto_desc.h"
43 #include "fuzz.h"
43 44
44 static void svr_remoteclosed(void); 45 static void svr_remoteclosed(void);
45 static void svr_algos_initialise(void); 46 static void svr_algos_initialise(void);
46 47
47 struct serversession svr_ses; /* GLOBAL */ 48 struct serversession svr_ses; /* GLOBAL */
182 { 183 {
183 /* must be after we've done with username etc */ 184 /* must be after we've done with username etc */
184 session_cleanup(); 185 session_cleanup();
185 } 186 }
186 187
188 #if DROPBEAR_FUZZ
189 /* longjmp before cleaning up svr_opts */
190 if (fuzz.do_jmp) {
191 longjmp(fuzz.jmp, 1);
192 }
193 #endif
194
187 if (svr_opts.hostkey) { 195 if (svr_opts.hostkey) {
188 sign_key_free(svr_opts.hostkey); 196 sign_key_free(svr_opts.hostkey);
189 svr_opts.hostkey = NULL; 197 svr_opts.hostkey = NULL;
190 } 198 }
191 for (i = 0; i < DROPBEAR_MAX_PORTS; i++) { 199 for (i = 0; i < DROPBEAR_MAX_PORTS; i++) {
192 m_free(svr_opts.addresses[i]); 200 m_free(svr_opts.addresses[i]);
193 m_free(svr_opts.ports[i]); 201 m_free(svr_opts.ports[i]);
194 } 202 }
195 203
204
196 exit(exitcode); 205 exit(exitcode);
197 206
198 } 207 }
199 208
200 /* priority is priority as with syslog() */ 209 /* priority is priority as with syslog() */
236 245
237 /* called when the remote side closes the connection */ 246 /* called when the remote side closes the connection */
238 static void svr_remoteclosed() { 247 static void svr_remoteclosed() {
239 248
240 m_close(ses.sock_in); 249 m_close(ses.sock_in);
241 m_close(ses.sock_out); 250 if (ses.sock_in != ses.sock_out) {
251 m_close(ses.sock_out);
252 }
242 ses.sock_in = -1; 253 ses.sock_in = -1;
243 ses.sock_out = -1; 254 ses.sock_out = -1;
244 dropbear_close("Exited normally"); 255 dropbear_close("Exited normally");
245 256
246 } 257 }