comparison common-session.c @ 1580:7f2be495dff6 coverity

merge coverity
author Matt Johnston <matt@ucc.asn.au>
date Sun, 04 Mar 2018 15:07:09 +0800
parents 399d8eb961b5
children 60fceff95858
comparison
equal deleted inserted replaced
1545:0b991dec7ab9 1580:7f2be495dff6
73 ses.last_packet_time_keepalive_recv = now; 73 ses.last_packet_time_keepalive_recv = now;
74 ses.last_packet_time_idle = now; 74 ses.last_packet_time_idle = now;
75 ses.last_packet_time_any_sent = 0; 75 ses.last_packet_time_any_sent = 0;
76 ses.last_packet_time_keepalive_sent = 0; 76 ses.last_packet_time_keepalive_sent = 0;
77 77
78 #if DROPBEAR_FUZZ
79 if (!fuzz.fuzzing)
80 #endif
81 {
78 if (pipe(ses.signal_pipe) < 0) { 82 if (pipe(ses.signal_pipe) < 0) {
79 dropbear_exit("Signal pipe failed"); 83 dropbear_exit("Signal pipe failed");
80 } 84 }
81 setnonblocking(ses.signal_pipe[0]); 85 setnonblocking(ses.signal_pipe[0]);
82 setnonblocking(ses.signal_pipe[1]); 86 setnonblocking(ses.signal_pipe[1]);
83
84 ses.maxfd = MAX(ses.maxfd, ses.signal_pipe[0]); 87 ses.maxfd = MAX(ses.maxfd, ses.signal_pipe[0]);
85 ses.maxfd = MAX(ses.maxfd, ses.signal_pipe[1]); 88 ses.maxfd = MAX(ses.maxfd, ses.signal_pipe[1]);
89 }
86 90
87 ses.writepayload = buf_new(TRANS_MAX_PAYLOAD_LEN); 91 ses.writepayload = buf_new(TRANS_MAX_PAYLOAD_LEN);
88 ses.transseq = 0; 92 ses.transseq = 0;
89 93
90 ses.readbuf = NULL; 94 ses.readbuf = NULL;
152 FD_ZERO(&readfd); 156 FD_ZERO(&readfd);
153 dropbear_assert(ses.payload == NULL); 157 dropbear_assert(ses.payload == NULL);
154 158
155 /* We get woken up when signal handlers write to this pipe. 159 /* We get woken up when signal handlers write to this pipe.
156 SIGCHLD in svr-chansession is the only one currently. */ 160 SIGCHLD in svr-chansession is the only one currently. */
161 #if DROPBEAR_FUZZ
162 if (!fuzz.fuzzing)
163 #endif
164 {
157 FD_SET(ses.signal_pipe[0], &readfd); 165 FD_SET(ses.signal_pipe[0], &readfd);
166 }
158 167
159 /* set up for channels which can be read/written */ 168 /* set up for channels which can be read/written */
160 setchannelfds(&readfd, &writefd, writequeue_has_space); 169 setchannelfds(&readfd, &writefd, writequeue_has_space);
161 170
162 /* Pending connections to test */ 171 /* Pending connections to test */
296 305
297 while (!isempty(&ses.writequeue)) { 306 while (!isempty(&ses.writequeue)) {
298 buf_free(dequeue(&ses.writequeue)); 307 buf_free(dequeue(&ses.writequeue));
299 } 308 }
300 309
310 m_free(ses.newkeys);
311 #ifndef DISABLE_ZLIB
312 if (ses.keys->recv.zstream != NULL) {
313 if (inflateEnd(ses.keys->recv.zstream) == Z_STREAM_ERROR) {
314 dropbear_exit("Crypto error");
315 }
316 m_free(ses.keys->recv.zstream);
317 }
318 #endif
319
301 m_free(ses.remoteident); 320 m_free(ses.remoteident);
302 m_free(ses.authstate.pw_dir); 321 m_free(ses.authstate.pw_dir);
303 m_free(ses.authstate.pw_name); 322 m_free(ses.authstate.pw_name);
304 m_free(ses.authstate.pw_shell); 323 m_free(ses.authstate.pw_shell);
305 m_free(ses.authstate.pw_passwd); 324 m_free(ses.authstate.pw_passwd);
325 } 344 }
326 345
327 void send_session_identification() { 346 void send_session_identification() {
328 buffer *writebuf = buf_new(strlen(LOCAL_IDENT "\r\n") + 1); 347 buffer *writebuf = buf_new(strlen(LOCAL_IDENT "\r\n") + 1);
329 buf_putbytes(writebuf, (const unsigned char *) LOCAL_IDENT "\r\n", strlen(LOCAL_IDENT "\r\n")); 348 buf_putbytes(writebuf, (const unsigned char *) LOCAL_IDENT "\r\n", strlen(LOCAL_IDENT "\r\n"));
330 writebuf_enqueue(writebuf, 0); 349 writebuf_enqueue(writebuf);
331 } 350 }
332 351
333 static void read_session_identification() { 352 static void read_session_identification() {
334 /* max length of 255 chars */ 353 /* max length of 255 chars */
335 char linebuf[256]; 354 char linebuf[256];