comparison common-session.c @ 1052:e40d1b63b6a6 coverity

merge
author Matt Johnston <matt@ucc.asn.au>
date Sat, 28 Feb 2015 23:25:16 +0800
parents c2a50c9f509e
children 4c733310c21d
comparison
equal deleted inserted replaced
1046:b8f4b7027191 1052:e40d1b63b6a6
32 #include "ssh.h" 32 #include "ssh.h"
33 #include "dbrandom.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 #include "netio.h"
37 38
38 static void checktimeouts(); 39 static void checktimeouts();
39 static long select_timeout(); 40 static long select_timeout();
40 static int ident_readln(int fd, char* buf, int count); 41 static int ident_readln(int fd, char* buf, int count);
41 static void read_session_identification(); 42 static void read_session_identification();
164 SIGCHLD in svr-chansession is the only one currently. */ 165 SIGCHLD in svr-chansession is the only one currently. */
165 FD_SET(ses.signal_pipe[0], &readfd); 166 FD_SET(ses.signal_pipe[0], &readfd);
166 167
167 /* set up for channels which can be read/written */ 168 /* set up for channels which can be read/written */
168 setchannelfds(&readfd, &writefd); 169 setchannelfds(&readfd, &writefd);
170
171 /* Pending connections to test */
172 set_connect_fds(&writefd);
169 173
170 val = select(ses.maxfd+1, &readfd, &writefd, NULL, &timeout); 174 val = select(ses.maxfd+1, &readfd, &writefd, NULL, &timeout);
171 175
172 if (exitflag) { 176 if (exitflag) {
173 dropbear_exit("Terminated by signal"); 177 dropbear_exit("Terminated by signal");
212 * will be ready for a new packet */ 216 * will be ready for a new packet */
213 if (ses.payload != NULL) { 217 if (ses.payload != NULL) {
214 process_packet(); 218 process_packet();
215 } 219 }
216 } 220 }
217 221
218 /* if required, flush out any queued reply packets that 222 /* if required, flush out any queued reply packets that
219 were being held up during a KEX */ 223 were being held up during a KEX */
220 maybe_flush_reply_queue(); 224 maybe_flush_reply_queue();
225
226 handle_connect_fds(&writefd);
221 227
222 /* process pipes etc for the channels, ses.dataallowed == 0 228 /* process pipes etc for the channels, ses.dataallowed == 0
223 * during rekeying ) */ 229 * during rekeying ) */
224 channelio(&readfd, &writefd); 230 channelio(&readfd, &writefd);
225 231
272 /* After these are freed most functions will exit */ 278 /* After these are freed most functions will exit */
273 #ifdef DROPBEAR_CLEANUP 279 #ifdef DROPBEAR_CLEANUP
274 /* listeners call cleanup functions, this should occur before 280 /* listeners call cleanup functions, this should occur before
275 other session state is freed. */ 281 other session state is freed. */
276 remove_all_listeners(); 282 remove_all_listeners();
283
284 remove_connect_pending();
277 285
278 while (!isempty(&ses.writequeue)) { 286 while (!isempty(&ses.writequeue)) {
279 buf_free(dequeue(&ses.writequeue)); 287 buf_free(dequeue(&ses.writequeue));
280 } 288 }
281 289
575 int any = 0; 583 int any = 0;
576 unsigned int i; 584 unsigned int i;
577 585
578 TRACE(("update_channel_prio")) 586 TRACE(("update_channel_prio"))
579 587
588 if (ses.sock_out < 0) {
589 TRACE(("leave update_channel_prio: no socket"))
590 return;
591 }
592
580 new_prio = DROPBEAR_PRIO_BULK; 593 new_prio = DROPBEAR_PRIO_BULK;
581 for (i = 0; i < ses.chansize; i++) { 594 for (i = 0; i < ses.chansize; i++) {
582 struct Channel *channel = ses.channels[i]; 595 struct Channel *channel = ses.channels[i];
583 if (!channel || channel->prio == DROPBEAR_CHANNEL_PRIO_EARLY) { 596 if (!channel || channel->prio == DROPBEAR_CHANNEL_PRIO_EARLY) {
584 if (channel && channel->prio == DROPBEAR_CHANNEL_PRIO_EARLY) { 597 if (channel && channel->prio == DROPBEAR_CHANNEL_PRIO_EARLY) {