comparison svr-session.c @ 1040:2b4fd440399d

Free memory before exiting. Based on patch from Thorsten Horstmann. Client side is not complete.
author Matt Johnston <matt@ucc.asn.au>
date Tue, 24 Feb 2015 22:01:33 +0800
parents 0bb16232e7c4
children 3fb883a6aa81
comparison
equal deleted inserted replaced
1039:d0e6dd5af46e 1040:2b4fd440399d
76 #endif 76 #endif
77 NULL /* Null termination is mandatory. */ 77 NULL /* Null termination is mandatory. */
78 }; 78 };
79 79
80 static void 80 static void
81 svr_session_cleanup(void) 81 svr_session_cleanup(void) {
82 {
83 /* free potential public key options */ 82 /* free potential public key options */
84 svr_pubkey_options_cleanup(); 83 svr_pubkey_options_cleanup();
84
85 m_free(svr_ses.addrstring);
86 m_free(svr_ses.childpids);
87 m_free(svr_ses.remotehost);
85 } 88 }
86 89
87 static void 90 static void
88 svr_sessionloop() { 91 svr_sessionloop() {
89 if (svr_ses.connect_time != 0 92 if (svr_ses.connect_time != 0
148 151
149 /* failure exit - format must be <= 100 chars */ 152 /* failure exit - format must be <= 100 chars */
150 void svr_dropbear_exit(int exitcode, const char* format, va_list param) { 153 void svr_dropbear_exit(int exitcode, const char* format, va_list param) {
151 154
152 char fmtbuf[300]; 155 char fmtbuf[300];
156 int i;
153 157
154 if (!sessinitdone) { 158 if (!sessinitdone) {
155 /* before session init */ 159 /* before session init */
156 snprintf(fmtbuf, sizeof(fmtbuf), 160 snprintf(fmtbuf, sizeof(fmtbuf),
157 "Early exit: %s", format); 161 "Early exit: %s", format);
181 { 185 {
182 /* must be after we've done with username etc */ 186 /* must be after we've done with username etc */
183 session_cleanup(); 187 session_cleanup();
184 } 188 }
185 189
190 if (svr_opts.hostkey) {
191 sign_key_free(svr_opts.hostkey);
192 svr_opts.hostkey = NULL;
193 }
194 for (i = 0; i < DROPBEAR_MAX_PORTS; i++) {
195 m_free(svr_opts.addresses[i]);
196 m_free(svr_opts.ports[i]);
197 }
198
186 exit(exitcode); 199 exit(exitcode);
187 200
188 } 201 }
189 202
190 /* priority is priority as with syslog() */ 203 /* priority is priority as with syslog() */