Mercurial > dropbear
comparison common-channel.c @ 1046:b8f4b7027191 coverity
merge
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Tue, 24 Feb 2015 22:48:34 +0800 |
parents | d0e6dd5af46e |
children | 01eea88963f3 |
comparison
equal
deleted
inserted
replaced
1014:37c510c2ac7c | 1046:b8f4b7027191 |
---|---|
400 | 400 |
401 | 401 |
402 /* Send the close message and set the channel as closed */ | 402 /* Send the close message and set the channel as closed */ |
403 static void send_msg_channel_close(struct Channel *channel) { | 403 static void send_msg_channel_close(struct Channel *channel) { |
404 | 404 |
405 TRACE(("enter send_msg_channel_close %p", channel)) | 405 TRACE(("enter send_msg_channel_close %p", (void*)channel)) |
406 if (channel->type->closehandler | 406 if (channel->type->closehandler |
407 && !channel->close_handler_done) { | 407 && !channel->close_handler_done) { |
408 channel->type->closehandler(channel); | 408 channel->type->closehandler(channel); |
409 channel->close_handler_done = 1; | 409 channel->close_handler_done = 1; |
410 } | 410 } |
584 | 584 |
585 if (IS_DROPBEAR_SERVER || (channel->writefd != STDOUT_FILENO)) { | 585 if (IS_DROPBEAR_SERVER || (channel->writefd != STDOUT_FILENO)) { |
586 /* close the FDs in case they haven't been done | 586 /* close the FDs in case they haven't been done |
587 * yet (they might have been shutdown etc) */ | 587 * yet (they might have been shutdown etc) */ |
588 TRACE(("CLOSE writefd %d", channel->writefd)) | 588 TRACE(("CLOSE writefd %d", channel->writefd)) |
589 close(channel->writefd); | 589 m_close(channel->writefd); |
590 TRACE(("CLOSE readfd %d", channel->readfd)) | 590 TRACE(("CLOSE readfd %d", channel->readfd)) |
591 close(channel->readfd); | 591 m_close(channel->readfd); |
592 TRACE(("CLOSE errfd %d", channel->errfd)) | 592 TRACE(("CLOSE errfd %d", channel->errfd)) |
593 close(channel->errfd); | 593 m_close(channel->errfd); |
594 } | 594 } |
595 | 595 |
596 if (!channel->close_handler_done | 596 if (!channel->close_handler_done |
597 && channel->type->closehandler) { | 597 && channel->type->closehandler) { |
598 channel->type->closehandler(channel); | 598 channel->type->closehandler(channel); |
614 | 614 |
615 struct Channel *channel; | 615 struct Channel *channel; |
616 | 616 |
617 channel = getchannel(); | 617 channel = getchannel(); |
618 | 618 |
619 TRACE(("enter recv_msg_channel_request %p", channel)) | 619 TRACE(("enter recv_msg_channel_request %p", (void*)channel)) |
620 | 620 |
621 if (channel->sent_close) { | 621 if (channel->sent_close) { |
622 TRACE(("leave recv_msg_channel_request: already closed channel")) | 622 TRACE(("leave recv_msg_channel_request: already closed channel")) |
623 return; | 623 return; |
624 } | 624 } |
999 } else { | 999 } else { |
1000 closein = 1; | 1000 closein = 1; |
1001 } | 1001 } |
1002 } else { | 1002 } else { |
1003 TRACE(("CLOSE some fd %d", fd)) | 1003 TRACE(("CLOSE some fd %d", fd)) |
1004 close(fd); | 1004 m_close(fd); |
1005 closein = closeout = 1; | 1005 closein = closeout = 1; |
1006 } | 1006 } |
1007 | 1007 |
1008 if (closeout && (fd == channel->readfd)) { | 1008 if (closeout && (fd == channel->readfd)) { |
1009 channel->readfd = FD_CLOSED; | 1009 channel->readfd = FD_CLOSED; |
1022 /* if we called shutdown on it and all references are gone, then we | 1022 /* if we called shutdown on it and all references are gone, then we |
1023 * need to close() it to stop it lingering */ | 1023 * need to close() it to stop it lingering */ |
1024 if (channel->type->sepfds && channel->readfd == FD_CLOSED | 1024 if (channel->type->sepfds && channel->readfd == FD_CLOSED |
1025 && channel->writefd == FD_CLOSED && channel->errfd == FD_CLOSED) { | 1025 && channel->writefd == FD_CLOSED && channel->errfd == FD_CLOSED) { |
1026 TRACE(("CLOSE (finally) of %d", fd)) | 1026 TRACE(("CLOSE (finally) of %d", fd)) |
1027 close(fd); | 1027 m_close(fd); |
1028 } | 1028 } |
1029 } | 1029 } |
1030 | 1030 |
1031 | 1031 |
1032 #if defined(USING_LISTENERS) || defined(DROPBEAR_CLIENT) | 1032 #if defined(USING_LISTENERS) || defined(DROPBEAR_CLIENT) |
1139 buf_putbyte(ses.writepayload, SSH_MSG_REQUEST_FAILURE); | 1139 buf_putbyte(ses.writepayload, SSH_MSG_REQUEST_FAILURE); |
1140 encrypt_packet(); | 1140 encrypt_packet(); |
1141 } | 1141 } |
1142 | 1142 |
1143 struct Channel* get_any_ready_channel() { | 1143 struct Channel* get_any_ready_channel() { |
1144 size_t i; | |
1144 if (ses.chancount == 0) { | 1145 if (ses.chancount == 0) { |
1145 return NULL; | 1146 return NULL; |
1146 } | 1147 } |
1147 size_t i; | |
1148 for (i = 0; i < ses.chansize; i++) { | 1148 for (i = 0; i < ses.chansize; i++) { |
1149 struct Channel *chan = ses.channels[i]; | 1149 struct Channel *chan = ses.channels[i]; |
1150 if (chan | 1150 if (chan |
1151 && !(chan->sent_eof || chan->recv_eof) | 1151 && !(chan->sent_eof || chan->recv_eof) |
1152 && !(chan->await_open || chan->initconn)) { | 1152 && !(chan->await_open || chan->initconn)) { |